Skip to content

Commit

Permalink
Prevent headers to be sent twice
Browse files Browse the repository at this point in the history
  • Loading branch information
samalba authored and indexzero committed Dec 27, 2013
1 parent 1457980 commit 8332e74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8332e74

Please sign in to comment.