From 2c44039a7c30b190043da654ee7e5aed0304e979 Mon Sep 17 00:00:00 2001 From: Jake Furler Date: Wed, 14 Jun 2017 14:46:54 +1000 Subject: [PATCH] issue #953: stop using writeHead object.keys in web-incoming.js results in a non-deterministic ordering of keys, which means that in web-outgoing writeHead might be called before setHeader, which throws an error --- lib/http-proxy/passes/web-outgoing.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/http-proxy/passes/web-outgoing.js b/lib/http-proxy/passes/web-outgoing.js index 05ded88..46352f6 100644 --- a/lib/http-proxy/passes/web-outgoing.js +++ b/lib/http-proxy/passes/web-outgoing.js @@ -137,9 +137,10 @@ module.exports = { // <-- writeStatusCode: function writeStatusCode(req, res, proxyRes) { // From Node.js docs: response.writeHead(statusCode[, statusMessage][, headers]) if(proxyRes.statusMessage) { - res.writeHead(proxyRes.statusCode, proxyRes.statusMessage); + res.statusCode = proxyRes.statusCode; + res.statusMessage = proxyRes.statusMessage; } else { - res.writeHead(proxyRes.statusCode); + res.statusCode = proxyRes.statusCode; } }