diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index bc974cff80fd01..60ed6779c47979 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -296,21 +296,21 @@ function _storeHeader(firstLine, headers) { header: firstLine }; - var key; - if (headers === this[outHeadersKey]) { - for (key in headers) { - const entry = headers[key]; - processHeader(this, state, entry[0], entry[1], false); - } - } else if (Array.isArray(headers)) { - for (var i = 0; i < headers.length; i++) { - const entry = headers[i]; - processHeader(this, state, entry[0], entry[1], true); - } - } else if (headers) { - for (key in headers) { - if (hasOwnProperty(headers, key)) { - processHeader(this, state, key, headers[key], true); + if (headers) { + if (headers === this[outHeadersKey]) { + for (const key in headers) { + const entry = headers[key]; + processHeader(this, state, entry[0], entry[1], false); + } + } else if (Array.isArray(headers)) { + for (const entry of headers) { + processHeader(this, state, entry[0], entry[1], true); + } + } else { + for (const key in headers) { + if (hasOwnProperty(headers, key)) { + processHeader(this, state, key, headers[key], true); + } } } }