Skip to content

Commit 64fa520

Browse files
author
glortho
committed
Add tests for testing forwarding of continuation frames
This adds two tests that send payloads below and at the threshold for continuation frames. Using node 0.12.7 both tests pass. Using node 4.1.2 the test below the threshold passes but the other fails.
1 parent b5a6d0e commit 64fa520

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

test/lib-http-proxy-test.js

+64-1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,69 @@ describe('lib/http-proxy.js', function() {
487487
});
488488
});
489489
});
490+
491+
it('should forward frames with single frame payload (including on node 4.x)', function (done) {
492+
var payload = Array(65529).join('0');
493+
var ports = { source: gen.port, proxy: gen.port };
494+
var proxy = httpProxy.createProxyServer({
495+
target: 'ws://127.0.0.1:' + ports.source,
496+
ws: true
497+
}),
498+
proxyServer = proxy.listen(ports.proxy),
499+
destiny = new ws.Server({ port: ports.source }, function () {
500+
var client = new ws('ws://127.0.0.1:' + ports.proxy);
501+
502+
client.on('open', function () {
503+
client.send(payload);
504+
});
505+
506+
client.on('message', function (msg) {
507+
expect(msg).to.be('Hello over websockets');
508+
client.close();
509+
proxyServer.close();
510+
destiny.close();
511+
done();
512+
});
513+
});
514+
515+
destiny.on('connection', function (socket) {
516+
socket.on('message', function (msg) {
517+
expect(msg).to.be(payload);
518+
socket.send('Hello over websockets');
519+
});
520+
});
521+
});
490522

491-
})
523+
it('should forward continuation frames with big payload (including on node 4.x)', function (done) {
524+
var payload = Array(65530).join('0');
525+
var ports = { source: gen.port, proxy: gen.port };
526+
var proxy = httpProxy.createProxyServer({
527+
target: 'ws://127.0.0.1:' + ports.source,
528+
ws: true
529+
}),
530+
proxyServer = proxy.listen(ports.proxy),
531+
destiny = new ws.Server({ port: ports.source }, function () {
532+
var client = new ws('ws://127.0.0.1:' + ports.proxy);
533+
534+
client.on('open', function () {
535+
client.send(payload);
536+
});
537+
538+
client.on('message', function (msg) {
539+
expect(msg).to.be('Hello over websockets');
540+
client.close();
541+
proxyServer.close();
542+
destiny.close();
543+
done();
544+
});
545+
});
546+
547+
destiny.on('connection', function (socket) {
548+
socket.on('message', function (msg) {
549+
expect(msg).to.be(payload);
550+
socket.send('Hello over websockets');
551+
});
552+
});
553+
});
554+
});
492555
});

0 commit comments

Comments
 (0)