From fe5c2bd884ec4eb3294dfebb12e395bf24dbdac0 Mon Sep 17 00:00:00 2001 From: Nik 'Fire Eater' Krimm Date: Mon, 11 Sep 2023 18:05:35 -0500 Subject: [PATCH] [489] Fixes => content-types can have semi-colons, and we need to parse around this. lint --- app/steps/sendProxyRequest.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/steps/sendProxyRequest.js b/app/steps/sendProxyRequest.js index 67c8bb2a..9fbd5159 100644 --- a/app/steps/sendProxyRequest.js +++ b/app/steps/sendProxyRequest.js @@ -36,22 +36,17 @@ function sendProxyRequest(Container) { proxyReq.on('error', reject); - // this guy should go elsewhere, down the chain - if (options.parseReqBody) { - // We are parsing the body ourselves so we need to write the body content - // and then manually end the request. - - //if (bodyContent instanceof Object) { - //throw new Error - //debugger; - //bodyContent = JSON.stringify(bodyContent); - //} + // We are parsing the body ourselves so we need to write the body content + // and then manually end the request. if (bodyContent.length) { var body = bodyContent; var contentType = proxyReq.getHeader('Content-Type'); - if (contentType === 'x-www-form-urlencoded' || contentType === 'application/x-www-form-urlencoded') { + // contentTypes may contain semi-colon + // example: "application/x-www-form-urlencoded; charset=UTF-8" + + if (contentType && contentType.match('x-www-form-urlencoded')) { try { var params = JSON.parse(body); body = Object.keys(params).map(function (k) { return k + '=' + params[k]; }).join('&');