James Coglan
569ec1d62e
Perform more stringent checks on request headers so that it should not be possible to get a driver for requests with invalid headers.
2017-10-30 22:53:34 +00:00
James Coglan
1325828a9e
Add ping/pong events to the API.
2017-08-02 21:57:47 +01:00
James Coglan
751c77aa1d
Replace the built-in Node HTTP parser with the http-parser-js package.
2017-07-30 19:34:41 +01:00
James Coglan
b76f4e27d0
Correct the HTTP parser magic numbers. The numbers we had were correct for Node 0.12 but not for releases since then.
2017-07-30 19:26:45 +01:00
James Coglan
6a92cacf62
Apply masking to messages once the payload has been placed in the frame buffer rather than mutating the original message.
2016-04-27 22:28:58 +01:00
James Coglan
7f3bb13b5c
In draft-75/76, convert all non-string values to strings before sending.
2016-01-06 23:20:47 +00:00
James Coglan
ffa0aa3a8f
Convert numbers to strings when sending frames.
...
In draft-75/76, passing a number to text() or frame() results in the
sender allocating a buffer of that size and sending it to the other
peer, leaking random blocks of memory.
In hybi, a call to text(), binary() or ping() with a number will fail,
because the input is expected to be a buffer and so an internal method
call fails.
Both kinds of driver now convert numbers to strings, which is what
browsers do with calls to send().
2016-01-06 23:12:44 +00:00
James Coglan
b0b0d69ce4
Throw a more helpful error if a client driver is created with an invalid URL.
2015-10-17 21:44:36 +01:00
James Coglan
5b59d0fcd8
Use the modulo operator rather than Math.floor() to check whether the draft-76 keys are legit.
2015-10-02 21:35:22 +01:00
James Coglan
68990a260b
Close the connection if a draft-76 client sends a Sec-WebSocket-Key header where the numeric value is a non-integer multiple of the number of spaces.
2015-10-01 23:47:15 +01:00
James Coglan
89e2a7da82
Emit a protocol error when a closing frame has a 1-byte payload.
2015-07-17 22:05:26 +01:00
James Coglan
70ef5440c4
Emit close code 1000 if the closing frame does not contain one.
2015-07-15 18:04:02 +01:00
James Coglan
c8e5f1eb78
A few stylistic tweaks.
2015-07-11 23:26:49 +01:00
James Coglan
eb5e39e7e3
Standardise the words used to refer to chunks of parser input.
2015-07-10 22:37:54 +01:00
James Coglan
a95f68080e
Use the buffer.{read,write}UInt{16,32}BE functions to parse and write numbers rather than implementing such things ourselves.
2015-07-10 20:01:44 +01:00
James Coglan
14937dd365
Emit an error event *after* setting the ready state to 3.
2015-07-08 20:14:14 +01:00
James Coglan
780dd331fe
The 'connect' event should emit a ConnectEvent object.
2015-07-07 21:33:15 +01:00
James Coglan
4a3d51cc5b
Incorporate StreamReader into Draft75 so that it retains input and recovers safely from exceptions in event listeners.
2015-07-07 21:30:06 +01:00
James Coglan
ed17186354
In the Hybi driver, perform parser state changes before validating and emitting events. This protects the parser against errors thrown by event listeners.
2015-07-07 20:36:30 +01:00
James Coglan
1df1293456
Change stage in the Base.shutdown() method to that all parsers stop processing input.
2015-07-04 21:07:34 +01:00
James Coglan
d901d3e48d
If an event listener emits an error, close the connection with code 1011.
2015-07-04 20:54:22 +01:00
Victor Gama
5f6873ebc0
Ensure message is always defined
2015-07-04 18:33:59 +01:00
Victor Gama
309b5651a7
Implement 'pong' command to hybi.js
2015-07-04 18:33:59 +01:00
James Coglan
0034f5fe19
Fail the connection when the server receives an invalid Sec-WebSocket-Extensions header.
2015-03-26 08:51:34 +00:00
James Coglan
8a0235ef51
Don't send a close frame in response to receiving one, if we already sent a close frame.
2015-03-12 12:58:43 +00:00
James Coglan
23d0a9ea5e
Don't parse incoming data if the client is already closed. This stops the headers being interpreted as WebSocket data if the client is closed before receiving the server's handshake. Fixes https://github.com/faye/websocket-extensions-node/issues/1 .
2015-02-21 12:34:37 +00:00
James Coglan
8cf42d6050
Apply @zingaburga's StreamReader optimisations from https://github.com/faye/websocket-driver-node/issues/10 .
2015-02-16 20:07:40 +00:00
James Coglan
ebe4ce1382
Because Driver.frame() will now admit input when in readyState 2 (to allow for async extension shutdown), the Messages stream should use the text() and binary() methods that will block messages in that state.
2015-02-16 09:51:40 +00:00
James Coglan
daa37974c6
Don't emit further error/close events if the driver is already closing.
2015-02-16 09:08:10 +00:00
James Coglan
cc5e5c245e
Use Extensions.close(callback) to make sure close follows all pending messages.
...
viz.: https://github.com/faye/websocket-extensions-node/commit/1b77290e8279f654089eac963942309fb19b9312
2015-02-15 13:18:21 +00:00
James Coglan
bdc081ab57
Adapt to the changes to the HTTPParser API introduced in iojs.
2015-02-02 21:06:51 +00:00
James Coglan
5cba268409
Throw an error if drivers are created with unrecognised options.
2014-12-17 22:18:06 +00:00
James Coglan
23675e08ee
Don't expose the internal frame structure of messages to extensions; they should not be able to depend on seeing the actual frame boundaries off the wire because that requires all extensions to leave them intact.
2014-12-06 22:08:37 +00:00
James Coglan
66f46330e7
Remove some blank lines.
2014-12-05 19:36:06 +00:00
James Coglan
7376f48d6a
Catch errors raised by Extensions.activate().
2014-12-02 22:53:16 +00:00
James Coglan
330fa2073d
Don't assume that messages coming out of extensions have anything but the standard websocket-extensions API.
2014-11-29 01:54:20 +00:00
James Coglan
58474a837c
Populate the Message.data field before handing off to extensions.
2014-11-29 01:13:18 +00:00
James Coglan
82182eb348
Close the Extensions object when ending the session.
2014-11-29 00:55:02 +00:00
James Coglan
94041e7a86
websocket-extensions uses Node-style callbacks rather than emitting error events.
2014-11-27 09:32:49 +00:00
James Coglan
e73f7db754
Rename validFrame() to validFrameRsv().
2014-11-26 09:59:08 +00:00
James Coglan
0efc0ebb8d
Don't pass the driver into the Extensions constructor.
2014-11-25 23:17:39 +00:00
James Coglan
f904131d21
Extract the Extensions class into another module.
2014-11-25 21:14:17 +00:00
James Coglan
ee664ba6c9
Decouple Extensions and individual extension libs from the Driver.fail() method, emitting errors instead.
2014-11-25 19:42:54 +00:00
James Coglan
538239b761
Move the header-parsing functions into class methods on Extensions.
2014-11-25 09:11:58 +00:00
James Coglan
2bc103c781
Adjust the data structures in the Extensions parser so that the server sets the order of extensions, per the spec.
2014-11-24 23:03:50 +00:00
James Coglan
eceb59e2fb
Implement the client-side framework for extensions.
2014-11-24 22:05:31 +00:00
James Coglan
40341c5439
The Client driver requires the crypto module for generating keys.
2014-11-24 00:41:34 +00:00
James Coglan
396637d463
Extract permessage-deflate into a separate module.
2014-11-23 21:46:04 +00:00
James Coglan
c986ad231c
Enable strict mode on all source files.
2014-11-23 20:09:26 +00:00
James Coglan
ef897eed1c
Implement deflate compression on server-to-client messages.
2014-11-23 19:45:02 +00:00