Skip to content
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

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

BlackYoup
Copy link
Contributor

According to the HTTP spec, a 304 Not Modified response can have a Content-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 an aborted event if the response has a status code of 304 with a Content-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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BlackYoup BlackYoup requested a review from a team as a code owner August 18, 2020 20:00
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Aug 18, 2020
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@Trott
Copy link
Member

Trott commented Aug 21, 2020

This could use some more reviews (and any thoughts on semver-ness). @nodejs/net @nodejs/http

@Trott Trott added the review wanted PRs that need reviews. label Aug 21, 2020
@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2020
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Aug 23, 2020

@rickyes rickyes added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 24, 2020
@rickyes rickyes added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 6, 2020
@github-actions github-actions bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Sep 6, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2020

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)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http: allow Content-Length header for 304 responses

Fixes #31037

PR-URL: #34835
Reviewed-By: James M Snell [email protected]
Reviewed-By: Ricky Zhou [email protected]

[detached HEAD 0a6e3bda] http: allow Content-Length header for 304 responses
Author: Arnaud Lefebvre [email protected]
Date: Tue Aug 18 21:28:31 2020 +0200
2 files changed, 37 insertions(+)
create mode 100644 test/parallel/test-http-allow-content-length-304.js
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
Update test/parallel/test-http-allow-content-length-304.js

Co-authored-by: mscdex [email protected]

PR-URL: #34835
Reviewed-By: James M Snell [email protected]
Reviewed-By: Ricky Zhou [email protected]

[detached HEAD e55739a9] Update test/parallel/test-http-allow-content-length-304.js
Author: Arnaud Lefebvre [email protected]
Date: Wed Aug 19 01:07:11 2020 +0200
1 file changed, 1 insertion(+), 1 deletion(-)

Successfully rebased and updated refs/heads/master.
✔ 0a6e3bdabb2ebd800237c34c68f022bf6a2f5b4c
✔ 0:0 skipping fixes-url fixes-url
✔ 0:0 blank line after title line-after-title
✔ 0:0 line-lengths are valid line-length
✔ 0:0 metadata is at end of message metadata-end
✔ 3:8 PR-URL is valid. pr-url
✔ 0:0 reviewers are valid reviewers
✔ 0:0 valid subsystems subsystem
✔ 0:0 Title is formatted correctly. title-format
⚠ 0:50 Title should be <= 50 columns. title-length
✖ e55739a9e0623284ee652b385aeab2ab7aa6e183
✔ 0:0 skipping fixes-url fixes-url
✔ 0:0 blank line after title line-after-title
✔ 0:0 line-lengths are valid line-length
✔ 0:0 metadata is at end of message metadata-end
✔ 3:8 PR-URL is valid. pr-url
✔ 0:0 reviewers are valid reviewers
✖ 0:0 Missing subsystem. subsystem
✔ 0:0 Title is formatted correctly. title-format
⚠ 0:50 Title should be <= 50 columns. title-length

ℹ Please fix the commit message and try again.

@BlackYoup
Copy link
Contributor Author

Regarding the failure, should I squash both commits into one?

@rickyes rickyes removed the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Sep 10, 2020
@rickyes
Copy link
Contributor

rickyes commented Sep 10, 2020

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.

@trivikr trivikr requested a review from mscdex September 10, 2020 22:06
@nodejs-github-bot

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]>
@Trott
Copy link
Member

Trott commented Sep 11, 2020

Landed in 23d6c42

@Trott Trott merged commit 23d6c42 into nodejs:master Sep 11, 2020
ruyadorno pushed a commit that referenced this pull request Sep 17, 2020
Fixes: #31037

PR-URL: #34835
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ricky Zhou <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Sep 21, 2020
4 tasks
joesepi pushed a commit to joesepi/node that referenced this pull request Jan 8, 2021
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http Issues or PRs related to the http subsystem. review wanted PRs that need reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants