GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allowing HEAD method to work with keep-alive by josephhackman · Pull Request #34231 · nodejs/node

Conversation

@josephhackman

@josephhackman josephhackman commented Jul 6, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes: #28438

This approach specifically retains the non-hanging of 204 requests while allowing HEAD to function correctly with keeping sockets open. I check for 204 + 304 specifically rather than the HEAD method because the method is in _http_server, not _http_outgoing, though it could be passed along if that's preferred.

Checklist

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added the http Issues and PRs related to the http subsystem. label Jul 6, 2020
@josephhackman josephhackman changed the title Pr 1 Allowing HEAD method to work with keep-alive Jul 7, 2020
bnoordhuis
bnoordhuis reviewed Jul 7, 2020
View reviewed changes

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, thanks for doing this. Can you also test the 304 status code?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis approved these changes Jul 8, 2020
View reviewed changes
@nodejs-github-bot

nodejs-github-bot commented Jul 8, 2020

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/32247/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 9, 2020
CI Relability 2020-07-09 JaneaSystems/nodejs-reliability#32
Open
CI Relability 2020-07-10 JaneaSystems/nodejs-reliability#33
Open
CI Relability 2020-07-11 JaneaSystems/nodejs-reliability#34
Open
CI Relability 2020-07-12 JaneaSystems/nodejs-reliability#35
Open
CI Relability 2020-07-13 JaneaSystems/nodejs-reliability#36
Open
@josephhackman

josephhackman commented Jul 13, 2020

Copy link
Copy Markdown
Contributor Author

It seems that the only tests failing are flakey. Is there additional action required on my part?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jul 13, 2020

Copy link
Copy Markdown
Member

@josephhackman No action on your part is needed but since this is a fairly subtle change it'd be good to get at least one more sign-off from a @nodejs/http member.

josephhackman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jul 14, 2020
CI Relability 2020-07-14 JaneaSystems/nodejs-reliability#37
Open
10 tasks
jasnell
jasnell reviewed Aug 2, 2020
View reviewed changes
Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephhackman added a commit to josephhackman/node that referenced this pull request Aug 3, 2020
@josephhackman
http: Updating OutgoingMessage to contain the request method
9880a03
Re-factoring to address PR comment. The logic here gets somewhat
complicated with regards to the if-elseif block circa line 434.
The goal of this PR is to prevent head requests from having their
Content-Length or Content-Encoding headers cleared except when
necessary, which is when the response code is 204 or 304. In trying
to address comment, I'm balancing between a larger re-factor than
absolutely needed and somewhat ugly control logic.

Refs: nodejs#34231 (comment)
@josephhackman
josephhackman requested a review from a team as a code owner August 10, 2020 16:06
@ronag

ronag commented Aug 10, 2020

Copy link
Copy Markdown
Member

Just as a side note. HEAD requests have an edge case due to which many HTTP clients (including the node one) will always close the connection and ignore keep-alive.

#12396
https://github.com/mcollina/undici/issues/258

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josephhackman
josephhackman force-pushed the pr-1 branch from 96776bf to c087959 Compare August 11, 2020 13:14
@josephhackman

josephhackman commented Aug 12, 2020

Copy link
Copy Markdown
Contributor Author

Just as a side note. HEAD requests have an edge case due to which many HTTP clients (including the node one) will always close the connection and ignore keep-alive.

#12396
mcollina/undici#258

This isn't quite true. The node client will close a the connection on a HEAD response if neither the Content-Length or Content-Encoding headers are set. This PR contains a test that empirically verifies this, using the node server and client. This PR does not make any changes to the node client, so it will continue doing what it did before, which is sometimes closing the socket on head-requests.

These headers are allowed by the HTTP standard, so this change should keep the node server just as compliant as it always was, while allowing any properly-implemented client to be substantially faster while sending many HEAD requests to collect metadata.

On the other hand, it is possible that non-standards-compliant clients exist that would malfunction seeing these headers on a HEAD request. I think that's a minimal risk because most people don't implement their own HTTP client library, but many people do mess with the headers on their servers. This leads me to expect that clients tend to be standards-compliant, and if anything, hardened.

Refs: https://tools.ietf.org/html/rfc7231#section-3.3
Refs: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josephhackman josephhackman mentioned this pull request Aug 13, 2020
Potential Regression/Change: Connection doesn't reset on HEAD #34758
Closed
@trivikr
trivikr requested a review from jasnell September 11, 2020 05:44
@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 17, 2020
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 17, 2020
@nodejs-github-bot

nodejs-github-bot commented Nov 17, 2020

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/34434/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag

ronag commented Dec 27, 2020

Copy link
Copy Markdown
Member

This needs another approval. I'm not comfortable in my own knowledge here to give the second one.

@nodejs/http

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag ronag added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Dec 27, 2020
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 27, 2020
@nodejs-github-bot

nodejs-github-bot commented Dec 27, 2020

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/35102/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Dec 31, 2020
View reviewed changes
Comment thread test/parallel/test-http-reuse-socket.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Dec 31, 2020
View reviewed changes
@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 3, 2021
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 3, 2021
@nodejs-github-bot

nodejs-github-bot commented Jan 3, 2021

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/35224/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josephhackman @aduh95
http: make HEAD method to work with keep-alive
7afa533
Fixes: nodejs#28438

PR-URL: nodejs#34231
Reviewed-By: James M Snell <[email protected]>
@aduh95
aduh95 force-pushed the pr-1 branch from 479338c to 7afa533 Compare January 3, 2021 21:54
@aduh95

aduh95 commented Jan 3, 2021

Copy link
Copy Markdown
Contributor

Landed in 7afa533 🎉 Thanks a lot for your contribution!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95
aduh95 merged commit 7afa533 into nodejs:master Jan 3, 2021
danielleadams pushed a commit that referenced this pull request Jan 12, 2021
@josephhackman @danielleadams
http: make HEAD method to work with keep-alive
954a369
Fixes: #28438

PR-URL: #34231
Reviewed-By: James M Snell <[email protected]>
@danielleadams danielleadams mentioned this pull request Jan 12, 2021
v15.6.0 proposal #36889
Merged
targos pushed a commit that referenced this pull request May 1, 2021
@josephhackman @targos
http: make HEAD method to work with keep-alive
5064822
Fixes: #28438

PR-URL: #34231
Reviewed-By: James M Snell <[email protected]>
@danielleadams danielleadams mentioned this pull request May 3, 2021
v14.17.0 proposal #38507
Merged
@fluggo

fluggo commented May 18, 2021

Copy link
Copy Markdown

I'm not convinced this was a good change. My HEAD methods with status 200 now send content-length: 0 by default, and this is very much not allowed by RFC7230:

A server MAY send a Content-Length header field in a response to a
HEAD request (Section 4.3.2 of [RFC7231]); 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 response if the same request had used the GET method.

Seems to me the sensible default would have been transfer-encoding: chunked.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina mentioned this pull request Jun 4, 2021
Potential breaking change on v14.17.0 #38922
Closed
@targos targos added the dont-land-on-v12.x label Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis approved these changes
@jasnell jasnell jasnell approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. http Issues and PRs related to the http subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

http server respond with inappropriate default headers for HEAD method

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@josephhackman @nodejs-github-bot @bnoordhuis @ronag @aduh95 @fluggo @jasnell @targos
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.