Skip to content

Commit 6f35e44

Browse files
committed
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 0f871e1 commit 6f35e44

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
@@ -317,6 +317,7 @@ function storeHeader(self, state, field, value) {
317317
'Header name must be a valid HTTP Token ["' + field + '"]');
318318
}
319319
if (common._checkInvalidHeaderChar(value) === true) {
320+
debug('Header "%s" contains invalid characters', field);
320321
throw new TypeError('The header content contains invalid characters');
321322
}
322323
state.messageHeader += field + ': ' + escapeHeaderValue(value) + CRLF;
@@ -357,6 +358,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
357358
if (this._header)
358359
throw new Error('Can\'t set headers after they are sent.');
359360
if (common._checkInvalidHeaderChar(value) === true) {
361+
debug('Header "%s" contains invalid characters', name);
360362
throw new TypeError('The header content contains invalid characters');
361363
}
362364
if (this._headers === null)
@@ -534,6 +536,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
534536
'Trailer name must be a valid HTTP Token ["' + field + '"]');
535537
}
536538
if (common._checkInvalidHeaderChar(value) === true) {
539+
debug('Trailer "%s" contains invalid characters', field);
537540
throw new TypeError('The trailer content contains invalid characters');
538541
}
539542
this._trailer += field + ': ' + escapeHeaderValue(value) + CRLF;

0 commit comments

Comments
 (0)