-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
http: allow Content-Length header for 304 responses #34835
Conversation
Review requested:
|
This could use some more reviews (and any thoughts on semver-ness). @nodejs/net @nodejs/http |
Commit Queue failed- Loading data for nodejs/node/pull/34835 ✔ Done loading data for nodejs/node/pull/34835 ----------------------------------- PR info ------------------------------------ Title http: allow Content-Length header for 304 responses (#34835) Author Arnaud Lefebvre (@BlackYoup) Branch BlackYoup:issue-31037 -> nodejs:master Labels author ready, http, review wanted Commits 2 - http: allow Content-Length header for 304 responses - Update test/parallel/test-http-allow-content-length-304.js Committers 2 - Arnaud Lefebvre - GitHub PR-URL: https://github.com/nodejs/node/pull/34835 Reviewed-By: James M Snell Reviewed-By: Ricky Zhou <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/34835 Reviewed-By: James M Snell Reviewed-By: Ricky Zhou <[email protected]> -------------------------------------------------------------------------------- ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-08-23T11:16:38Z: https://ci.nodejs.org/job/node-test-pull-request/32902/ - Querying data for job/node-test-pull-request/32902/ ✔ Build data downloaded ✔ Last Jenkins CI successful ℹ This PR was created on Tue, 18 Aug 2020 20:00:38 GMT ✔ Approvals: 2 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/34835#pullrequestreview-472590480 ✔ - Ricky Zhou (@rickyes): https://github.com/nodejs/node/pull/34835#pullrequestreview-473555162 -------------------------------------------------------------------------------- ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/master up to date... From https://github.com/nodejs/node * branch master -> FETCH_HEAD ✔ origin/master is now up-to-date - Downloading patch for 34835 ✔ Downloaded patch to /home/runner/work/node/node/.ncu/34835/patch -------------------------------------------------------------------------------- Applying: http: allow Content-Length header for 304 responses Applying: Update test/parallel/test-http-allow-content-length-304.js ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4) |
Regarding the failure, should I squash both commits into one? |
Of course it's better if you can. But it doesn't matter, we can use the tool to squash both commits into one and land it. |
This comment has been minimized.
This comment has been minimized.
Fixes: nodejs#31037 PR-URL: nodejs#34835 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Landed in 23d6c42 |
Fixes: #31037 PR-URL: #34835 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: nodejs#31037 PR-URL: nodejs#34835 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
According to the HTTP spec, a
304 Not Modified
response can have aContent-Length
header:A server MAY send a Content-Length header field in a 304 (Not Modified) response to a conditional GET request (Section 4.1 of [RFC7232]); a server MUST NOT send Content-Length in such a response unless its field-value equals the decimal number of octets that would have been sent in the payload body of a 200 (OK) response to the same request.
On the other hand, the spec doesn't allow a 304 response to have a body:
A 304 response cannot contain a message-body; it is always terminated by the first empty line after the header fields.
Currently, the
http
request module will emit anaborted
event if the response has a status code of304
with aContent-Length
header. This pull request fixes this behavior and the request can successfully finish.This fixes issue #31037
I tried to integrate the fix in the best place I could find, let me know if there are better ways to fix this!
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes