Skip to content

Commit bad0d93

Browse files
evanlucasMylesBorins
authored andcommitted
http: add debug message for invalid header value
This makes it easier to see what header has an invalid value. PR-URL: #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>
1 parent ee10f21 commit bad0d93

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/_http_outgoing.js

+3
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ function storeHeader(self, state, field, value) {
315315
'Header name must be a valid HTTP Token ["' + field + '"]');
316316
}
317317
if (common._checkInvalidHeaderChar(value) === true) {
318+
debug('Header "%s" contains invalid characters', field);
318319
throw new TypeError('The header content contains invalid characters');
319320
}
320321
state.messageHeader += field + ': ' + escapeHeaderValue(value) + CRLF;
@@ -355,6 +356,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) {
355356
if (this._header)
356357
throw new Error('Can\'t set headers after they are sent.');
357358
if (common._checkInvalidHeaderChar(value) === true) {
359+
debug('Header "%s" contains invalid characters', name);
358360
throw new TypeError('The header content contains invalid characters');
359361
}
360362
if (this._headers === null)
@@ -532,6 +534,7 @@ OutgoingMessage.prototype.addTrailers = function(headers) {
532534
'Trailer name must be a valid HTTP Token ["' + field + '"]');
533535
}
534536
if (common._checkInvalidHeaderChar(value) === true) {
537+
debug('Trailer "%s" contains invalid characters', field);
535538
throw new TypeError('The header content contains invalid characters');
536539
}
537540
this._trailer += field + ': ' + escapeHeaderValue(value) + CRLF;

0 commit comments

Comments
 (0)