mirror of
https://github.com/http-party/node-http-proxy.git
synced 2026-02-01 17:46:18 +00:00
Merge pull request #640 from jayharris/master
Don't override connection header if Upgrading
This commit is contained in:
commit
896ee7c9c3
@ -47,12 +47,14 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
|
|||||||
outgoing.localAddress = options.localAddress;
|
outgoing.localAddress = options.localAddress;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Remark: If we are false set the connection: close. This is the right thing to do
|
// Remark: If we are false and not upgrading, set the connection: close. This is the right thing to do
|
||||||
// as node core doesn't handle this COMPLETELY properly yet.
|
// as node core doesn't handle this COMPLETELY properly yet.
|
||||||
//
|
//
|
||||||
if(!outgoing.agent) {
|
if(!outgoing.agent) {
|
||||||
outgoing.headers = outgoing.headers || {};
|
outgoing.headers = outgoing.headers || {};
|
||||||
outgoing.headers.connection = 'close';
|
if(typeof outgoing.headers.connection !== 'string' || outgoing.headers.connection.toLowerCase() !== 'upgrade') {
|
||||||
|
outgoing.headers.connection = 'close';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -38,6 +38,48 @@ describe('lib/http-proxy/common.js', function () {
|
|||||||
expect(outgoing.localAddress).to.eql('local.address');
|
expect(outgoing.localAddress).to.eql('local.address');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not override agentless upgrade header', function () {
|
||||||
|
var outgoing = {};
|
||||||
|
common.setupOutgoing(outgoing,
|
||||||
|
{
|
||||||
|
agent: undefined,
|
||||||
|
target: {
|
||||||
|
host : 'hey',
|
||||||
|
hostname : 'how',
|
||||||
|
socketPath: 'are',
|
||||||
|
port : 'you',
|
||||||
|
},
|
||||||
|
headers: {'connection': 'upgrade'},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method : 'i',
|
||||||
|
url : 'am',
|
||||||
|
headers : {'pro':'xy','overwritten':false}
|
||||||
|
});
|
||||||
|
expect(outgoing.headers.connection).to.eql('upgrade');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should override agentless non-upgrade header to close', function () {
|
||||||
|
var outgoing = {};
|
||||||
|
common.setupOutgoing(outgoing,
|
||||||
|
{
|
||||||
|
agent: undefined,
|
||||||
|
target: {
|
||||||
|
host : 'hey',
|
||||||
|
hostname : 'how',
|
||||||
|
socketPath: 'are',
|
||||||
|
port : 'you',
|
||||||
|
},
|
||||||
|
headers: {'connection': 'xyz'},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method : 'i',
|
||||||
|
url : 'am',
|
||||||
|
headers : {'pro':'xy','overwritten':false}
|
||||||
|
});
|
||||||
|
expect(outgoing.headers.connection).to.eql('close');
|
||||||
|
});
|
||||||
|
|
||||||
it('should set the agent to false if none is given', function () {
|
it('should set the agent to false if none is given', function () {
|
||||||
var outgoing = {};
|
var outgoing = {};
|
||||||
common.setupOutgoing(outgoing, {target:
|
common.setupOutgoing(outgoing, {target:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user