diff --git a/README.md b/README.md index f07e6d42a..fc33c4fc1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/server.js b/test/server.js index 0b9d88569..cef2b96b1 100644 --- a/test/server.js +++ b/test/server.js @@ -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) {