Skip to content

Commit 8332e74

Browse files
samalbaindexzero
authored andcommitted
Prevent headers to be sent twice
1 parent 1457980 commit 8332e74

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/node-http-proxy/http-proxy.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
333333
}
334334

335335
// Set the headers of the client response
336-
Object.keys(response.headers).forEach(function (key) {
337-
res.setHeader(key, response.headers[key]);
338-
});
339-
res.writeHead(response.statusCode);
336+
if (res.sentHeaders !== true) {
337+
Object.keys(response.headers).forEach(function (key) {
338+
res.setHeader(key, response.headers[key]);
339+
});
340+
res.writeHead(response.statusCode);
341+
}
340342

341343
function ondata(chunk) {
342344
if (res.writable) {

0 commit comments

Comments
 (0)