You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
http server respond with inappropriate default headers for HEAD method #28438
To implement a HTTP keep alive mechanism, I use the http.Agent({ keepAlive: true }) and http.request({ agent, method, host, port }).
Everything is ok when the method is GET or TRACE and 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 HEAD method, there isn't a Content-Length: 0 or Transfer-Encoding: chunked in the default header (but GET has 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: 0 or Transfer-Encoding: chunked should be setted in response header, I think this should be a default behavior.
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
This 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.
This 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.
Activity
[-]http server respond with inappropriate headers for `HEAD` method[/-][+]http server respond with inappropriate default headers for `HEAD` method[/+]jimmiehansson commentedon Jun 29, 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
http: make HEAD method to work with keep-alive
http: make HEAD method to work with keep-alive
http: make HEAD method to work with keep-alive
wa-Nadoo commentedon Jun 15, 2021
It seems this issue should be reopened because the bugfix commit was reverted.
nawed2611 commentedon May 6, 2022
Hey! Can I work on this?
http: include Content-Length in HEAD responses for keep-alive
github-actions commentedon Jun 27, 2026
This 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.
github-actions commentedon Jul 28, 2026
This 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.