diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 262b1d9f87e4d8..67a8d6f8bb8233 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -209,23 +209,31 @@ function _storeHeader(firstLine, headers) { messageHeader: firstLine }; - if (headers) { - var keys = Object.keys(headers); - var isArray = Array.isArray(headers); - var field, value; - - for (var i = 0, l = keys.length; i < l; i++) { - var key = keys[i]; - if (isArray) { - field = headers[key][0]; - value = headers[key][1]; + var i; + var j; + var field; + var value; + if (headers instanceof Array) { + for (i = 0; i < headers.length; ++i) { + field = headers[i][0]; + value = headers[i][1]; + + if (value instanceof Array) { + for (j = 0; j < value.length; j++) { + storeHeader(this, state, field, value[j]); + } } else { - field = key; - value = headers[key]; + storeHeader(this, state, field, value); } + } + } else if (headers) { + var keys = Object.keys(headers); + for (i = 0; i < keys.length; ++i) { + field = keys[i]; + value = headers[field]; - if (Array.isArray(value)) { - for (var j = 0; j < value.length; j++) { + if (value instanceof Array) { + for (j = 0; j < value.length; j++) { storeHeader(this, state, field, value[j]); } } else {