diff --git a/lib/_http_server.js b/lib/_http_server.js index f77b8f6a7e7867..34e7b6d29c2cae 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -213,10 +213,8 @@ function writeHead(statusCode, reason, obj) { if (k) this.setHeader(k, obj[k]); } } - if (k === undefined) { - if (this._header) { - throw new errors.Error('ERR_HTTP_HEADERS_SENT'); - } + if (k === undefined && this._header) { + throw new errors.Error('ERR_HTTP_HEADERS_SENT'); } // only progressive api is used headers = this[outHeadersKey];