Skip to content

Commit 855cebd

Browse files
ArGGujcrugzz
authored andcommitted
Added websocket set-cookie headers test
1 parent 8bfd90c commit 855cebd

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

test/lib-http-proxy-test.js

+38-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,43 @@ describe('lib/http-proxy.js', function() {
407407

408408
});
409409

410-
410+
it('should pass all set-cookie headers to client', function (done) {
411+
var ports = { source: gen.port, proxy: gen.port };
412+
var proxy = httpProxy.createProxyServer({
413+
target: 'ws://127.0.0.1:' + ports.source,
414+
ws: true
415+
}),
416+
proxyServer = proxy.listen(ports.proxy),
417+
destiny = new ws.Server({ port: ports.source }, function () {
418+
var key = new Buffer(Math.random().toString(35)).toString('base64');
419+
420+
var requestOptions = {
421+
port: ports.proxy,
422+
host: '127.0.0.1',
423+
headers: {
424+
'Connection': 'Upgrade',
425+
'Upgrade': 'websocket',
426+
'Host': 'ws://127.0.0.1',
427+
'Sec-WebSocket-Version': 13,
428+
'Sec-WebSocket-Key': key
429+
}
430+
};
431+
432+
var req = http.request(requestOptions);
433+
434+
req.on('upgrade', function (res, socket, upgradeHead) {
435+
expect(res.headers['set-cookie'].length).to.be(2);
436+
done();
437+
});
438+
439+
req.end();
440+
});
441+
442+
destiny.on('headers', function (headers) {
443+
headers.push('Set-Cookie: test1=test1');
444+
headers.push('Set-Cookie: test2=test2');
445+
});
446+
});
447+
411448
})
412449
});

0 commit comments

Comments
 (0)