diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 23b850d1522c97..acc8ba08e7a577 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -547,7 +547,7 @@ function _storeHeader(firstLine, headers) { } if (!state.contLen && !state.te) { - if (!this._hasBody) { + if (!this._hasBody && this.req.method !== 'HEAD') { // Make sure we don't end the 0\r\n\r\n at the end of the message. this.chunkedEncoding = false; } else if (!this.useChunkedEncodingByDefault) { @@ -932,7 +932,7 @@ function strictContentLength(msg) { return ( msg.strictContentLength && msg._contentLength != null && - msg._hasBody && + (msg._hasBody || msg.req.method === 'HEAD') && !msg._removedContLen && !msg.chunkedEncoding && !msg.hasHeader('transfer-encoding')