Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for maxHttpBufferSize option with websocket #499

Merged
merged 2 commits into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
24 changes: 22 additions & 2 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,14 +1143,34 @@ describe('server', function () {
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
engine.on('connection', function (conn) {
conn.on('message', function (msg) {
console.log(msg);
done(new Error('Test invalidation (message is longer than allowed)'));
});
});
socket.on('open', function () {
socket.send('aasdasdakjhasdkjhasdkjhasdkjhasdkjhasdkjhasdkjha');
});
socket.on('close', function () {
done();
});
});
});

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');
});
socket.on('close', function () {
done();
});
});
setTimeout(done, 1000);
});

it('should receive data when getting a message shorter than maxHttpBufferSize when polling', function (done) {
Expand Down