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: Setting content-type on reply object does not work correctly and/or hangs server #3283
Comments
I think it will not override the type when ever a user set the Lines 136 to 137 in a04f4c9
|
Example 1: Example 2: When using a custom Lines 139 to 191 in a04f4c9
So, it directly pass Line 380 in a04f4c9
Then onSendEnd cannot properly throw and send the error message.Lines 429 to 431 in a04f4c9
Example 3: Lines 170 to 173 in a04f4c9
|
We do have 2 test-case against the invalid payload, however it is checked inside the fastify/test/reply-error.test.js Lines 398 to 445 in a04f4c9
|
what is confusing about this is that
ok, hopefully that is in the docs somewhere. Thanks ! |
I understand the problem and I want to work on this issue. Can I take it? |
go for it! |
Thanks. |
I think this can be closed as resolved by #3285. |
馃挰 Bug report
It seems that
fastify
tries to force guess thecontent-type
of the response, and does ONLY allow to override it on thereply
object if it matches what it has guessed/determined, but even that does not work correctly all the time.example 1
this works b/c
.send
is sending a text string, hencefastify
will take the override in.headers()
. Btw, the override also works in this example w/o adding thecharset
(contrary to example 3 below).example 2
this does NOT work -
.send
is sending an object, hencefastify
determinesapplication/json; charset=utf-8
and will simply ignore the override in.headers()
... more importantly: this now hangs the server forever, the response will never come throughexample 3
looking at the code you'd think this would work, we're sending an object and
fastify
will guessapplication/json
and hence use the override in.headers()
. It doesn't. It sendsapplication/json; charset=utf-8
, which does NOT match what was specified in.headers()
.Summary:
example 1: it uses the override
example 2: it does NOT use the override and hangs
example 3: it does NOT use the override although the logic is very similar to example 1
Your Environment
The text was updated successfully, but these errors were encountered: