Skip to content

Commit

Permalink
http: add debug message for invalid header value
Browse files Browse the repository at this point in the history
This makes it easier to see what header has an invalid value.

PR-URL: #9195
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Brian White <[email protected]>
  • Loading branch information
evanlucas authored and MylesBorins committed Feb 21, 2017
1 parent 72961d8 commit c359018
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,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;
Expand Down Expand Up @@ -355,6 +356,7 @@ OutgoingMessage.prototype.setHeader = function(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)
Expand Down Expand Up @@ -532,6 +534,7 @@ OutgoingMessage.prototype.addTrailers = function(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 header content contains invalid characters');
}
this._trailer += field + ': ' + escapeHeaderValue(value) + CRLF;
Expand Down

0 comments on commit c359018

Please sign in to comment.