mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
copy headers instead of referencing them so they don't unexpectedly get overwritten
This commit is contained in:
parent
69a693034e
commit
daa2ce0ee3
@ -31,9 +31,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
|
|||||||
function(e) { outgoing[e] = options[forward || 'target'][e]; }
|
function(e) { outgoing[e] = options[forward || 'target'][e]; }
|
||||||
);
|
);
|
||||||
|
|
||||||
['method', 'headers'].forEach(
|
outgoing.method = req.method
|
||||||
function(e) { outgoing[e] = req[e]; }
|
outgoing.headers = extend({},req.headers)
|
||||||
);
|
|
||||||
|
|
||||||
if (options.headers){
|
if (options.headers){
|
||||||
extend(outgoing.headers, options.headers);
|
extend(outgoing.headers, options.headers);
|
||||||
@ -141,7 +140,7 @@ common.urlJoin = function() {
|
|||||||
last = args[lastIndex],
|
last = args[lastIndex],
|
||||||
lastSegs = last.split('?'),
|
lastSegs = last.split('?'),
|
||||||
retSegs;
|
retSegs;
|
||||||
|
|
||||||
args[lastIndex] = lastSegs[0];
|
args[lastIndex] = lastSegs[0];
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -146,7 +146,7 @@ describe('lib/http-proxy/common.js', function () {
|
|||||||
{
|
{
|
||||||
method : 'i',
|
method : 'i',
|
||||||
url : 'am',
|
url : 'am',
|
||||||
headers : 'proxy'
|
headers : {pro:'xy'}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(outgoing.host).to.eql('how');
|
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.method).to.eql('i');
|
||||||
expect(outgoing.path).to.eql('am');
|
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);
|
expect(outgoing.port).to.eql(443);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user