Skip to content

Commit ec683b9

Browse files
committed
test new detection of connection: upgrade
1 parent 65a21bc commit ec683b9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,49 @@ describe('lib/http-proxy/common.js', function () {
5959
expect(outgoing.headers.connection).to.eql('upgrade');
6060
});
6161

62+
it('should not override agentless connection: contains upgrade', function () {
63+
var outgoing = {};
64+
common.setupOutgoing(outgoing,
65+
{
66+
agent: undefined,
67+
target: {
68+
host : 'hey',
69+
hostname : 'how',
70+
socketPath: 'are',
71+
port : 'you',
72+
},
73+
headers: {'connection': 'keep-alive, upgrade'}, // this is what Firefox sets
74+
},
75+
{
76+
method : 'i',
77+
url : 'am',
78+
headers : {'pro':'xy','overwritten':false}
79+
});
80+
expect(outgoing.headers.connection).to.eql('keep-alive, upgrade');
81+
});
82+
83+
it('should override agentless connection: contains improper upgrade', function () {
84+
// sanity check on upgrade regex
85+
var outgoing = {};
86+
common.setupOutgoing(outgoing,
87+
{
88+
agent: undefined,
89+
target: {
90+
host : 'hey',
91+
hostname : 'how',
92+
socketPath: 'are',
93+
port : 'you',
94+
},
95+
headers: {'connection': 'keep-alive, not upgrade'},
96+
},
97+
{
98+
method : 'i',
99+
url : 'am',
100+
headers : {'pro':'xy','overwritten':false}
101+
});
102+
expect(outgoing.headers.connection).to.eql('close');
103+
});
104+
62105
it('should override agentless non-upgrade header to close', function () {
63106
var outgoing = {};
64107
common.setupOutgoing(outgoing,

0 commit comments

Comments
 (0)