From 8332e744202ed9de94288d8f1c822cd9fe788983 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 21 Mar 2013 16:44:32 -0700 Subject: [PATCH] Prevent headers to be sent twice --- lib/node-http-proxy/http-proxy.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 890b6b0..e4a0c86 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -333,10 +333,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { } // Set the headers of the client response - Object.keys(response.headers).forEach(function (key) { - res.setHeader(key, response.headers[key]); - }); - res.writeHead(response.statusCode); + if (res.sentHeaders !== true) { + Object.keys(response.headers).forEach(function (key) { + res.setHeader(key, response.headers[key]); + }); + res.writeHead(response.statusCode); + } function ondata(chunk) { if (res.writable) {