diff --git a/lib/response.js b/lib/response.js index fede486c06..55b3a52c10 100644 --- a/lib/response.js +++ b/lib/response.js @@ -209,14 +209,6 @@ res.send = function send(body) { // freshness if (req.fresh) this.statusCode = 304; - // strip irrelevant headers - if (204 === this.statusCode || 304 === this.statusCode) { - this.removeHeader('Content-Type'); - this.removeHeader('Content-Length'); - this.removeHeader('Transfer-Encoding'); - chunk = ''; - } - // alter headers for 205 if (this.statusCode === 205) { this.set('Content-Length', '0') @@ -224,8 +216,12 @@ res.send = function send(body) { chunk = '' } - if (req.method === 'HEAD') { - // skip body for HEAD + if ( + req.method === 'HEAD' || + 204 === this.statusCode || + 304 === this.statusCode + ) { + // skip body this.end(); } else { // respond