Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Don't override 'connection' header if was set by the target server #260

Closed
wants to merge 3 commits into
from
@@ -224,7 +224,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
//
// Process the `reverseProxy` `response` when it's received.
//
- if (response.headers.connection) {
+ if (!response.headers.connection) {
if (req.headers.connection) { response.headers.connection = req.headers.connection }
else { response.headers.connection = 'close' }
}
@@ -244,7 +244,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
}
// Set the headers of the client response
- res.writeHead(response.statusCode, response.headers);
+ Object.keys(response.headers).forEach(function(key){
+ res.setHeader(key, response.headers[key]);
+ });
+ res.writeHead(response.statusCode);
// If `response.statusCode === 304`: No 'data' event and no 'end'
if (response.statusCode === 304) {