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
Darwin MacbookPro-2.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64 arm Darwin
Subsystem
http
What steps will reproduce the bug?
Just start the server and curl the results:
import{createServer}from'node:http';consthostname='127.0.0.1';constport=3000;constserver=createServer((req,res)=>{res.statusCode=200;res.setHeader('Content-Type','text/plain');res.end('Hello World');});server.listen(port,hostname,()=>{console.log(`Server running at http://${hostname}:${port}/`);});
curl -v http://127.0.0.1:3000/ to get the response header through GET; curl -I http://127.0.0.1:3000/ to get the response header through HEAD.
How often does it reproduce? Is there a required condition?
Always. No required condition.
What is the expected behavior? Why is that the expected behavior?
The HEAD HTTP method requests the metadata of a resource in the form of headers that the server would have sent if the GET method was used instead. This method can be used in cases where a URL might produce a large download, for example, a HEAD request can read the Content-Length header to check the file size before downloading the file with a GET.
HEAD requests are a bit different than other request methods without body because it is essentially GETs with body removed. It should be allowed to return all the headers that a GET request returns.
What do you see instead?
However, in the current http library, all responses without body will not return the Content-Length header:
Version
v23.5.0
Platform
Subsystem
http
What steps will reproduce the bug?
Just start the server and
curl
the results:curl -v http://127.0.0.1:3000/
to get the response header throughGET
;curl -I http://127.0.0.1:3000/
to get the response header throughHEAD
.How often does it reproduce? Is there a required condition?
Always. No required condition.
What is the expected behavior? Why is that the expected behavior?
According to MDN:
HEAD
requests are a bit different than other request methods without body because it is essentiallyGET
s with body removed. It should be allowed to return all the headers that aGET
request returns.What do you see instead?
However, in the current http library, all responses without body will not return the
Content-Length
header:node/lib/_http_outgoing.js
Line 550 in 7bc2946
Curl results:
-I
(HEAD
Requests)-v
(GET
Requests)Additional information
No response
The text was updated successfully, but these errors were encountered: