|
|
@ -314,21 +314,21 @@ function _storeHeader(firstLine, headers) { |
|
|
|
if (state.expect) this._send(''); |
|
|
|
} |
|
|
|
|
|
|
|
function storeHeader(self, state, field, value, validate) { |
|
|
|
function storeHeader(self, state, key, value, validate) { |
|
|
|
if (validate) { |
|
|
|
if (!checkIsHttpToken(field)) { |
|
|
|
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 (value === undefined) { |
|
|
|
throw new Error('Header "%s" value must not be undefined', field); |
|
|
|
throw new Error('Header "%s" value must not be undefined', key); |
|
|
|
} else 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.header += field + ': ' + escapeHeaderValue(value) + CRLF; |
|
|
|
matchHeader(self, state, field, value); |
|
|
|
state.header += key + ': ' + escapeHeaderValue(value) + CRLF; |
|
|
|
matchHeader(self, state, key, value); |
|
|
|
} |
|
|
|
|
|
|
|
function matchConnValue(self, state, value) { |
|
|
@ -374,7 +374,7 @@ function matchHeader(self, state, field, value) { |
|
|
|
} |
|
|
|
|
|
|
|
function validateHeader(msg, 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) |
|
|
@ -568,7 +568,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 + '"]'); |
|
|
|
} |
|
|
|