add body.close check for HEAD requests

This commit is contained in:
TJ Holowaychuk 2013-11-15 11:33:14 -08:00
parent 27d1336af5
commit cb682ed904

View file

@ -210,7 +210,12 @@ function *respond(next){
// Stream body // Stream body
if (body instanceof Stream) { if (body instanceof Stream) {
if (!~body.listeners('error').indexOf(this.onerror)) body.on('error', this.onerror); if (!~body.listeners('error').indexOf(this.onerror)) body.on('error', this.onerror);
if (head) return body.close(), res.end();
if (head) {
if (body.close) body.close();
return res.end();
}
return body.pipe(res); return body.pipe(res);
} }