From 2b260c997ad4efe4ed2064b264b4b546a59e7a67 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 1 Feb 2023 17:37:21 +0100 Subject: [PATCH] fix: throw if invalid content-type header (#1901) --- lib/core/request.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/request.js b/lib/core/request.js index 59e0b87f39d..e476fc1bcc1 100644 --- a/lib/core/request.js +++ b/lib/core/request.js @@ -284,6 +284,7 @@ function processHeaderValue (key, val) { } else if (headerCharRegex.exec(val) !== null) { throw new InvalidArgumentError(`invalid ${key} header`) } + return `${key}: ${val}\r\n` } @@ -313,11 +314,10 @@ function processHeader (request, key, val) { } else if ( request.contentType === null && key.length === 12 && - key.toLowerCase() === 'content-type' && - headerCharRegex.exec(val) === null + key.toLowerCase() === 'content-type' ) { request.contentType = val - request.headers += `${key}: ${val}\r\n` + request.headers += processHeaderValue(key, val) } else if ( key.length === 17 && key.toLowerCase() === 'transfer-encoding'