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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix invalid response for empty reply() (v8.x regression) #2277
Conversation
I'm not sure about this change. If client sets I think this is more of a client error. An empty response should use the status code 204. And in that case client should not try to parse the response. This has been actually reported: |
I'm pretty sure it's a bad idea to change the response to a 204 code in a generic way, and anyway is not within the scope of a bug fix. Regarding |
If this is likely to cause issues, I'm open to changing it to only set |
I didn't suggest to change the status code in hapi. I meant developers should use Actually, I'm not sure your proposed change can be considered a bug fix. It can be considered a breaking change too as it changes the response. If clients are configured to take action based on the type of the response, then this change will break their behavior. Application code needs to be changed too (
You are right. It is an application bug and your proposed change makes sense now. |
The bug fix can indeed be considered a breaking change depending on which angle you look at it from. Since the changed behavior is not mentioned in #2186, and we are very early in the current release, I want to label it as a bug fix for an unannounced regression. In any case, the docs doesn't mention what |
Your proposed change makes sense, an empty 200 response with the Maybe the old behavior was correct in some way, because a |
We encountered the same issue. Issuing a request with Wreck and replying |
@leftieFriele That sounds like a bug in Wreck. It should not try to parse a response with code 204. Edit: Related wreck pull request: hapijs/wreck#69. |
I think |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
The
content-type
header for empty responses used to not be set when callingreply(null)
,reply('')
, etc in the route handler.In 8.0 the header is set as
application/json
. This is a problem, as an empty string is not valid JSON, causing eg.$.ajax()
to cast aTypeError
when in JSON mode.This patch changes the
content-type
to plaintext/html
for empty responses, which is valid.