-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
http server respond with inappropriate default headers for HEAD method #28438
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
help 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.httpIssues and PRs related to the http subsystem.Issues and PRs related to the http subsystem.staleIssues 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.
Description
Activity
Metadata
Metadata
Assignees
Labels
help 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.httpIssues and PRs related to the http subsystem.Issues and PRs related to the http subsystem.staleIssues 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.
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.