http: add debug message for invalid header value

This makes it easier to see what header has an invalid value.

PR-URL: https://github.com/nodejs/node/pull/9195
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
Evan Lucas 2016-10-19 16:28:16 -05:00 коммит произвёл James M Snell
Родитель 40fd69668d
Коммит d93ab51088
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -317,6 +317,7 @@ function storeHeader(self, state, field, value) {
'Header name must be a valid HTTP Token ["' + field + '"]');
}
if (common._checkInvalidHeaderChar(value) === true) {
debug('Header "%s" contains invalid characters', field);
throw new TypeError('The header content contains invalid characters');
}
state.messageHeader += field + ': ' + escapeHeaderValue(value) + CRLF;
@ -357,6 +358,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
if (this._header)
throw new Error('Can\'t set headers after they are sent.');
if (common._checkInvalidHeaderChar(value) === true) {
debug('Header "%s" contains invalid characters', name);
throw new TypeError('The header content contains invalid characters');
}
if (this._headers === null)
@ -534,6 +536,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
'Trailer name must be a valid HTTP Token ["' + field + '"]');
}
if (common._checkInvalidHeaderChar(value) === true) {
debug('Trailer "%s" contains invalid characters', field);
throw new TypeError('The trailer content contains invalid characters');
}
this._trailer += field + ': ' + escapeHeaderValue(value) + CRLF;