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
Microsoft Windows NT 10.0.22631.0 x64 (but maybe not platform-specific)
Subsystem
node:http
What steps will reproduce the bug?
The Transfer-Encoding: chunked header is always added when there is no response body. There seems to be no way to remove it.
However, since this header is not added when the request method is HEAD, the response headers are different when the request method is GET and HEAD, which is against the HTTP specification.
Example server code:
import{createServer}from'node:http';import{finished}from'node:stream/promises';createServer(function(req,res){finished(req.resume()).then(()=>{res.writeHead(200,{'Cache-Control': 'no-store'});res.end();// No body}).catch((err)=>{this.emit('error',err);})}).listen(8000,'0.0.0.0');
A monkey patching solution I found is to always add the Content-Length: 0 header.
However, I'm not sure if this is really the intended behavior. I think it should be possible to send a response without adding a Content-Length: 0 header when there is no body.
Or, if it's intended behavior, it should be documented.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
I would guess that the generally expected behavior is that the Transfer-Encoding: chunked header is NOT added when there is no response body.
Version
22 (but maybe every version)
Platform
Subsystem
node:http
What steps will reproduce the bug?
The
Transfer-Encoding: chunked
header is always added when there is no response body. There seems to be no way to remove it.However, since this header is not added when the request method is HEAD, the response headers are different when the request method is GET and HEAD, which is against the HTTP specification.
Example server code:
GET:
HEAD:
A monkey patching solution I found is to always add the
Content-Length: 0
header.However, I'm not sure if this is really the intended behavior. I think it should be possible to send a response without adding a
Content-Length: 0
header when there is no body.Or, if it's intended behavior, it should be documented.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
I would guess that the generally expected behavior is that the
Transfer-Encoding: chunked
header is NOT added when there is no response body.What do you see instead?
.
Additional information
Perhaps this issue denoland/deno#20063 may be related.
The text was updated successfully, but these errors were encountered: