|
|
@ -374,39 +374,52 @@ OutgoingMessage.prototype._storeHeader = function (firstLine, headers) { |
|
|
|
// in the case of response it is: "HTTP/1.1 200 OK\r\n"
|
|
|
|
var messageHeader = firstLine; |
|
|
|
var field, value; |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (headers) { |
|
|
|
var keys = Object.keys(headers); |
|
|
|
var isArray = (Array.isArray(headers)); |
|
|
|
for (var i = 0, l = keys.length; i < l; i++) { |
|
|
|
var key = keys[i]; |
|
|
|
if (isArray) { |
|
|
|
field = headers[key][0]; |
|
|
|
value = headers[key][1]; |
|
|
|
} else { |
|
|
|
field = key; |
|
|
|
value = headers[key]; |
|
|
|
} |
|
|
|
|
|
|
|
function store(field, value) { |
|
|
|
messageHeader += field + ": " + value + CRLF; |
|
|
|
|
|
|
|
if (connectionExpression.test(field)) { |
|
|
|
sentConnectionHeader = true; |
|
|
|
if (closeExpression.test(value)) { |
|
|
|
this._last = true; |
|
|
|
self._last = true; |
|
|
|
} else { |
|
|
|
this.shouldKeepAlive = true; |
|
|
|
self.shouldKeepAlive = true; |
|
|
|
} |
|
|
|
|
|
|
|
} else if (transferEncodingExpression.test(field)) { |
|
|
|
sentTransferEncodingHeader = true; |
|
|
|
if (chunkExpression.test(value)) this.chunkedEncoding = true; |
|
|
|
if (chunkExpression.test(value)) self.chunkedEncoding = true; |
|
|
|
|
|
|
|
} else if (contentLengthExpression.test(field)) { |
|
|
|
sentContentLengthHeader = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (headers) { |
|
|
|
var keys = Object.keys(headers); |
|
|
|
var isArray = (Array.isArray(headers)); |
|
|
|
var i, l; |
|
|
|
|
|
|
|
for (i = 0, l = keys.length; i < l; i++) { |
|
|
|
var key = keys[i]; |
|
|
|
if (isArray) { |
|
|
|
field = headers[key][0]; |
|
|
|
value = headers[key][1]; |
|
|
|
} else { |
|
|
|
field = key; |
|
|
|
value = headers[key]; |
|
|
|
} |
|
|
|
|
|
|
|
if (Array.isArray(value)) { |
|
|
|
for (i = 0, l = value.length; i < l; i++) { |
|
|
|
store(field, value[i]); |
|
|
|
} |
|
|
|
} else { |
|
|
|
store(field, value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// keep-alive logic
|
|
|
|