Skip to content

Commit daa2ce0

Browse files
copy headers instead of referencing them so they don't unexpectedly get overwritten
1 parent 69a6930 commit daa2ce0

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/http-proxy/common.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
3131
function(e) { outgoing[e] = options[forward || 'target'][e]; }
3232
);
3333

34-
['method', 'headers'].forEach(
35-
function(e) { outgoing[e] = req[e]; }
36-
);
34+
outgoing.method = req.method
35+
outgoing.headers = extend({},req.headers)
3736

3837
if (options.headers){
3938
extend(outgoing.headers, options.headers);
@@ -141,7 +140,7 @@ common.urlJoin = function() {
141140
last = args[lastIndex],
142141
lastSegs = last.split('?'),
143142
retSegs;
144-
143+
145144
args[lastIndex] = lastSegs[0];
146145

147146
//

test/lib-http-proxy-common-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('lib/http-proxy/common.js', function () {
146146
{
147147
method : 'i',
148148
url : 'am',
149-
headers : 'proxy'
149+
headers : {pro:'xy'}
150150
});
151151

152152
expect(outgoing.host).to.eql('how');
@@ -156,7 +156,7 @@ describe('lib/http-proxy/common.js', function () {
156156

157157
expect(outgoing.method).to.eql('i');
158158
expect(outgoing.path).to.eql('am');
159-
expect(outgoing.headers).to.eql('proxy')
159+
expect(outgoing.headers.pro).to.eql('xy')
160160

161161
expect(outgoing.port).to.eql(443);
162162
});

0 commit comments

Comments
 (0)