From 5a5a41081165435867b4e5d3a2a269d099d21c56 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 1a893f8de..25343bcb5 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -325,10 +325,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) {