-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
res.sendStatus(205) returns a Reset Content
body
#4592
Comments
Thank you for the report! It looks like Express can only fix part of the issue, unfortunately. We can change it to send an empty body, but cannot send no body at all. This is because Node.js does not procide an API to send no body, instead sending a zero length body at minimum, which violates the spec: https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 If having the body is messing up the client, the change in Express is unlikely to be a complete fix and Node.js would also need to add 205 to the list of status codes that must not have a response body. |
Apologies, I just reread 205 and apparently it is slightly different from 204 and 304, in that it does have a payload, but just must be zero length. We can fix that here, but still can only guarantee the fix as long as the users use the Express methods like res.send, res.json, etc. Using res.end and res.write would require Node.js to add a rule as those methods are delivered by the Node.js framework.
|
Oops, I missed the details for HTTP 205. I thought it should behave exactly like 204 🐧
I think that is a fair deal, since users wanting to send HTTP 205 would probably use This is a workaround for now I think: res.status(205).send('')
|
I tried some fix at #4596. While it matches the spec (send a |
This is a breaking change that hurt our production services. I see expressjs is following semver, shouldn't this have increased the major number? Also, there's currently no way to disable this new functionality |
Would you consider a PR that adds a parameter |
Hi @everhardt thank you for the feedback. Yes, Express.js uses semver, but sometimes fixing bugs is a hard choice. Express.js considers violations of the HTTP specs to be bugs and the prior behavior, as pointed out by the OP, violated the HTTP spec so we fixed that bug. You can skip this functionality by using the underlying |
It seems that HTTP 204 and 205 responses should not have a response body:
res.sendStatus(204)
correctly returns no response body, butres.sendStatus(205)
returns aReset Content
string. Is this expected?How to reproduce
Express version:
4.17.1
Node.js version:
15.14.0
The text was updated successfully, but these errors were encountered: