add body.close check for HEAD requests

master
TJ Holowaychuk 2013-11-15 11:33:14 -08:00
parent 27d1336af5
commit cb682ed904
1 changed files with 6 additions and 1 deletions

View File

@ -210,7 +210,12 @@ function *respond(next){
// Stream body
if (body instanceof Stream) {
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);
}