From bad0d9367ede162134492754ea1d46df7954e312 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 30 Jan 2017 09:41:58 -0600 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Brian White --- lib/_http_outgoing.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index a7467168c5899f..2b0b158721f562 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -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; @@ -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) @@ -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;