Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add test for maxHttpBufferSize option with websocket
  • Loading branch information
Damien Arrachequesne committed Apr 7, 2017
commit 4f0b53267c96a789555fede723a5b0ccb646fe13
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ to a single process.
packet (`25000`)
- `upgradeTimeout` (`Number`): how many ms before an uncompleted transport upgrade is cancelled (`10000`)
- `maxHttpBufferSize` (`Number`): how many bytes or characters a message
can be when polling, before closing the session (to avoid DoS). Default
can be, before closing the session (to avoid DoS). Default
value is `10E7`.
- `allowRequest` (`Function`): A function that receives a given handshake
or upgrade request as its first parameter, and can decide whether to
Expand Down
16 changes: 16 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,22 @@ describe('server', function () {
setTimeout(done, 1000);
});

it('should not be receiving data when getting a message longer than maxHttpBufferSize (websocket)', function (done) {
var opts = { maxHttpBufferSize: 5 };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['websocket'] });
engine.on('connection', function (conn) {
conn.on('message', function (msg) {
done(new Error('Test invalidation (message is longer than allowed)'));
});
});
socket.on('open', function () {
socket.send('aasdasdakjhasdkjhasdkjhasdkjhasdkjhasdkjhasdkjha');
});
});
setTimeout(done, 1000);
});

it('should receive data when getting a message shorter than maxHttpBufferSize when polling', function (done) {
var opts = { allowUpgrades: false, transports: ['polling'], maxHttpBufferSize: 5 };
var engine = listen(opts, function (port) {
Expand Down