New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 [Bug]: Cannot set header to 'text/event-stream' with ctx.Set #2546
Comments
Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@michealroberts since the handler is a middleware and contains only one next you must have at least one handler with logic func TestSSEDefaults(t *testing.T) {
app := fiber.New(fiber.Config{
IdleTimeout: -1,
ReadTimeout: 0,
})
app.Use(New())
// needed
app.Get("/", func(ctx *fiber.Ctx) error {
return nil
})
t.Helper()
h := app.Handler()
// Test default GET response headers
ctx := &fasthttp.RequestCtx{}
ctx.Request.Header.SetMethod(fiber.MethodGet)
h(ctx)
utils.AssertEqual(t, "text/event-stream", string(ctx.Response.Header.Peek(fiber.HeaderContentType)))
utils.AssertEqual(t, "no-cache", string(ctx.Response.Header.Peek(fiber.HeaderCacheControl)))
utils.AssertEqual(t, "keep-alive", string(ctx.Response.Header.Peek(fiber.HeaderConnection)))
ctx.Response.Header.Set(fiber.HeaderConnection, "close")
ctx.Response.ConnectionClose()
app.Shutdown()
} |
@ReneWerner87 Ok the reason seems logical, but worth noting that this (i.e., my tests) were working on version 2.31.0 of Fiber ... |
yes as I said before |
@ReneWerner87 Totally understand. So you wouldn't consider that a breaking change? |
yes is a kind of breaking change for me this was more a bug, because a middleware without a real handler which processes the content and only forwards it to other middlewares is rather wrong this only affects those who had been using it incorrectly, so for 95% of people it is not a breaking change |
Yeh I also appreciate this. It's kind of a bug, but introduces a change that will break a lot of previous code. Could you update the release notes of 2.32.0 with a breaking change note please, this should really have been a v3 release RFC imho, but as it borders the line between bug and feature, it's a though one to partition. |
yes I can do |
Bug Description
As above, I had a middleware running on version 2.31.0 of Go finer, where I would utilise the following:
My associated test suite was passing on version 2.31.0 but on version 2.48.0 it seems to be failing, instead, the Content-Type header is still set to 'text/plain'
How to Reproduce
As above.
Expected Behavior
It should be able to set the Content-Type header to "text/event-stream".
Fiber Version
2.48.0
Code Snippet (optional)
Associated test (failing):
Checklist:
The text was updated successfully, but these errors were encountered: