Repository navigation
http server respond with inappropriate default headers for HEAD method #28438
Description
Activity
- changed the title
[-]http server respond with inappropriate headers for `HEAD` method[/-][+]http server respond with inappropriate default headers for `HEAD` method[/+]on Jun 26, 2019 Hey @abbshr
In contrary to GET this is the intended behavior for the HEAD requests as its simply a meta request of GET, excluding the body contents that you would typically have in GET, this seems like an expected behavior from the http server as there is no buffer or chunk to expect.
RFC-accordingly, depending on the request payload this may also lead to early termination.
Did i understand your problem correctly?
Also see the semantics of the HTTP payload https://tools.ietf.org/html/rfc7231#section-3.3- addedhttpIssues and PRs related to the http subsystem.Issues and PRs related to the http subsystem.
on Jul 28, 2019 - addedhelp wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.
on Jun 26, 2020 - added a commit that references this issue
on Jan 3, 2021 - added a commit that references this issue
on Jan 12, 2021 - added a commit that references this issue
on May 1, 2021 It seems this issue should be reopened because the bugfix commit was reverted.
Hey! Can I work on this?
- added a commit that references this issue
on Feb 21, 2026 github-actions commented
on Jun 27, 2026 on Jun 27, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jun 27, 2026 github-actions commented
on Jul 28, 2026 on Jul 28, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
To implement a HTTP keep alive mechanism, I use the
http.Agent({ keepAlive: true })andhttp.request({ agent, method, host, port }).Everything is ok when the method is
GETorTRACEand others, the agent reuse the TCP connection as I expect.But when changing the method to
HEAD, the agent close the connection when server responded.From the response header, the only different is that: for
HEADmethod, there isn't aContent-Length: 0orTransfer-Encoding: chunkedin the default header (butGEThas by default), so the HTTP parser think this connection should not be kept alive.But from the RFC, we can infer that if keep-alive was enabled, either
Content-Length: 0orTransfer-Encoding: chunkedshould be setted in response header, I think this should be a default behavior.