|
|
@ -374,11 +374,35 @@ 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; |
|
|
|
|
|
|
|
function store(field, value) { |
|
|
|
messageHeader += field + ": " + value + CRLF; |
|
|
|
|
|
|
|
if (connectionExpression.test(field)) { |
|
|
|
sentConnectionHeader = true; |
|
|
|
if (closeExpression.test(value)) { |
|
|
|
self._last = true; |
|
|
|
} else { |
|
|
|
self.shouldKeepAlive = true; |
|
|
|
} |
|
|
|
|
|
|
|
} else if (transferEncodingExpression.test(field)) { |
|
|
|
sentTransferEncodingHeader = 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)); |
|
|
|
for (var i = 0, l = keys.length; i < l; i++) { |
|
|
|
var i, l; |
|
|
|
|
|
|
|
for (i = 0, l = keys.length; i < l; i++) { |
|
|
|
var key = keys[i]; |
|
|
|
if (isArray) { |
|
|
|
field = headers[key][0]; |
|
|
@ -388,23 +412,12 @@ OutgoingMessage.prototype._storeHeader = function (firstLine, headers) { |
|
|
|
value = headers[key]; |
|
|
|
} |
|
|
|
|
|
|
|
messageHeader += field + ": " + value + CRLF; |
|
|
|
|
|
|
|
if (connectionExpression.test(field)) { |
|
|
|
sentConnectionHeader = true; |
|
|
|
if (closeExpression.test(value)) { |
|
|
|
this._last = true; |
|
|
|
} else { |
|
|
|
this.shouldKeepAlive = true; |
|
|
|
if (Array.isArray(value)) { |
|
|
|
for (i = 0, l = value.length; i < l; i++) { |
|
|
|
store(field, value[i]); |
|
|
|
} |
|
|
|
|
|
|
|
} else if (transferEncodingExpression.test(field)) { |
|
|
|
sentTransferEncodingHeader = true; |
|
|
|
if (chunkExpression.test(value)) this.chunkedEncoding = true; |
|
|
|
|
|
|
|
} else if (contentLengthExpression.test(field)) { |
|
|
|
sentContentLengthHeader = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
store(field, value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|