From 5fa01b8781fb7a1d370efc6c762fb89ca87f2c5e Mon Sep 17 00:00:00 2001 From: Andrew Pietila Date: Sun, 30 Aug 2020 20:59:02 -0500 Subject: [PATCH] If header set multiple times, move to array. Believed compatible with Koa, Connect frameworks. Unable to identify what edp is, believed to be compatible assuming headers is passed directly to the Node.JS response handler. --- src/main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 7617df1..1768bc6 100644 --- a/src/main.js +++ b/src/main.js @@ -35,7 +35,24 @@ function parse(buffer) { line = lines.shift(); if (line) { line = line.split(':'); - headers[line[0]] = line[1]; + if (headers[line[0]]) { + if (typeof (headers[line[0]]) === "string") { + let oldHeader = headers[line[0]]; + headers[line[0]] = []; + headers[line[0]].push(oldHeader); + } + if (line.length > 2) { + headers[line[0]].push(line.splice(1).join(':')); + } else { + headers[line[0]].push(line[1]); + } + } else { + if (line.length > 2) { + headers[line[0]] = line.splice(1).join(':'); + } else { + headers[line[0]] = line[1]; + } + } } else { break;