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
Then, an error "Can't set headers after they are sent." is thrown.
This issue is relevant to #207.
BTW, when the response.setHeader method was not called, the error is not thrown even if the response.writeHead method is called twice. This is another issue about Node.js.
In Server.prototype.respondNoGzip, the response.writeHead method is called when requested file is not cached.
// Don't end the request here, if we're streaming;
What is a case that the response.writeHead method must be called here?
Anyway, it should check whether headers were already sent or not by using response.headersSent or response._header.
if(!res._header){res.writeHead(status,headers);
The text was updated successfully, but these errors were encountered:
Hi, thank you for the great module.
So,
response.writeHead
method is called twice when the request is not aGET
request.For example:
Save a content file to
public/index.html
:Run this code as a server:
And run this code as a client (using request module):
Then, an error "Can't set headers after they are sent." is thrown.
This issue is relevant to #207.
BTW, when the
response.setHeader
method was not called, the error is not thrown even if theresponse.writeHead
method is called twice. This is another issue about Node.js.In
Server.prototype.respondNoGzip
, theresponse.writeHead
method is called when requested file is not cached.node-static/lib/node-static.js
Line 333 in e994d29
And, in
Server.prototype.finish
, theresponse.writeHead
method is called again when the request is not aGET
request.node-static/lib/node-static.js
Line 125 in e994d29
Also, a response body is made (i.e. it is piped to
response
) even if the request is aHEAD
request. (And that body may be discarded by the server.)node-static/lib/node-static.js
Line 379 in e994d29
I couldn't understand this comment:
node-static/lib/node-static.js
Line 122 in e994d29
What is a case that the
response.writeHead
method must be called here?Anyway, it should check whether headers were already sent or not by using
response.headersSent
orresponse._header
.The text was updated successfully, but these errors were encountered: