Skip to content

Commit 8aa7c51

Browse files
committed
Adding test cases on preventing upgrade override
1 parent d637b96 commit 8aa7c51

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

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

+42
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,48 @@ describe('lib/http-proxy/common.js', function () {
3838
expect(outgoing.localAddress).to.eql('local.address');
3939
});
4040

41+
it('should not override agentless upgrade header', function () {
42+
var outgoing = {};
43+
common.setupOutgoing(outgoing,
44+
{
45+
agent: undefined,
46+
target: {
47+
host : 'hey',
48+
hostname : 'how',
49+
socketPath: 'are',
50+
port : 'you',
51+
},
52+
headers: {'connection': 'upgrade'},
53+
},
54+
{
55+
method : 'i',
56+
url : 'am',
57+
headers : {'pro':'xy','overwritten':false}
58+
});
59+
expect(outgoing.headers.connection).to.eql('upgrade');
60+
});
61+
62+
it('should override agentless non-upgrade header to close', 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': 'xyz'},
74+
},
75+
{
76+
method : 'i',
77+
url : 'am',
78+
headers : {'pro':'xy','overwritten':false}
79+
});
80+
expect(outgoing.headers.connection).to.eql('close');
81+
});
82+
4183
it('should set the agent to false if none is given', function () {
4284
var outgoing = {};
4385
common.setupOutgoing(outgoing, {target:

0 commit comments

Comments
 (0)