|
|
@ -319,18 +319,18 @@ function _storeHeader(firstLine, headers) { |
|
|
|
if (state.sentExpect) this._send(''); |
|
|
|
} |
|
|
|
|
|
|
|
function storeHeader(self, state, field, value) { |
|
|
|
if (!checkIsHttpToken(field)) { |
|
|
|
function storeHeader(self, state, key, value) { |
|
|
|
if (typeof key !== 'string' || !key || !checkIsHttpToken(key)) { |
|
|
|
throw new TypeError( |
|
|
|
'Header name must be a valid HTTP Token ["' + field + '"]'); |
|
|
|
'Header name must be a valid HTTP Token ["' + key + '"]'); |
|
|
|
} |
|
|
|
if (checkInvalidHeaderChar(value)) { |
|
|
|
debug('Header "%s" contains invalid characters', field); |
|
|
|
debug('Header "%s" contains invalid characters', key); |
|
|
|
throw new TypeError('The header content contains invalid characters'); |
|
|
|
} |
|
|
|
state.messageHeader += field + ': ' + escapeHeaderValue(value) + CRLF; |
|
|
|
state.messageHeader += key + ': ' + escapeHeaderValue(value) + CRLF; |
|
|
|
|
|
|
|
if (connectionExpression.test(field)) { |
|
|
|
if (connectionExpression.test(key)) { |
|
|
|
state.sentConnectionHeader = true; |
|
|
|
if (connCloseExpression.test(value)) { |
|
|
|
self._last = true; |
|
|
@ -339,26 +339,26 @@ function storeHeader(self, state, field, value) { |
|
|
|
} |
|
|
|
if (connUpgradeExpression.test(value)) |
|
|
|
state.sentConnectionUpgrade = true; |
|
|
|
} else if (transferEncodingExpression.test(field)) { |
|
|
|
} else if (transferEncodingExpression.test(key)) { |
|
|
|
state.sentTransferEncodingHeader = true; |
|
|
|
if (trfrEncChunkExpression.test(value)) self.chunkedEncoding = true; |
|
|
|
|
|
|
|
} else if (contentLengthExpression.test(field)) { |
|
|
|
} else if (contentLengthExpression.test(key)) { |
|
|
|
state.sentContentLengthHeader = true; |
|
|
|
} else if (dateExpression.test(field)) { |
|
|
|
} else if (dateExpression.test(key)) { |
|
|
|
state.sentDateHeader = true; |
|
|
|
} else if (expectExpression.test(field)) { |
|
|
|
} else if (expectExpression.test(key)) { |
|
|
|
state.sentExpect = true; |
|
|
|
} else if (trailerExpression.test(field)) { |
|
|
|
} else if (trailerExpression.test(key)) { |
|
|
|
state.sentTrailer = true; |
|
|
|
} else if (upgradeExpression.test(field)) { |
|
|
|
} else if (upgradeExpression.test(key)) { |
|
|
|
state.sentUpgrade = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OutgoingMessage.prototype.setHeader = function setHeader(name, value) { |
|
|
|
if (!checkIsHttpToken(name)) |
|
|
|
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) |
|
|
|
throw new TypeError( |
|
|
|
'Header name must be a valid HTTP Token ["' + name + '"]'); |
|
|
|
if (value === undefined) |
|
|
@ -538,7 +538,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { |
|
|
|
field = key; |
|
|
|
value = headers[key]; |
|
|
|
} |
|
|
|
if (!checkIsHttpToken(field)) { |
|
|
|
if (typeof field !== 'string' || !field || !checkIsHttpToken(field)) { |
|
|
|
throw new TypeError( |
|
|
|
'Trailer name must be a valid HTTP Token ["' + field + '"]'); |
|
|
|
} |
|
|
|