diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 43919b1b5..a6aca80b0 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -31,9 +31,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) { function(e) { outgoing[e] = options[forward || 'target'][e]; } ); - ['method', 'headers'].forEach( - function(e) { outgoing[e] = req[e]; } - ); + outgoing.method = req.method; + outgoing.headers = extend({}, req.headers); if (options.headers){ extend(outgoing.headers, options.headers); @@ -141,7 +140,7 @@ common.urlJoin = function() { last = args[lastIndex], lastSegs = last.split('?'), retSegs; - + args[lastIndex] = lastSegs[0]; // diff --git a/test/lib-http-proxy-common-test.js b/test/lib-http-proxy-common-test.js index b74fd021f..149c4226b 100644 --- a/test/lib-http-proxy-common-test.js +++ b/test/lib-http-proxy-common-test.js @@ -146,7 +146,7 @@ describe('lib/http-proxy/common.js', function () { { method : 'i', url : 'am', - headers : 'proxy' + headers : {pro:'xy'} }); expect(outgoing.host).to.eql('how'); @@ -156,7 +156,7 @@ describe('lib/http-proxy/common.js', function () { expect(outgoing.method).to.eql('i'); expect(outgoing.path).to.eql('am'); - expect(outgoing.headers).to.eql('proxy') + expect(outgoing.headers.pro).to.eql('xy'); expect(outgoing.port).to.eql(443); });