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
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
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
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
d901d3e48d
If an event listener emits an error, close the connection with code 1011.
2015-07-04 20:54:22 +01:00
Victor Gama
90b8c9d23a
Add tests to others socket states
2015-07-04 18:34:00 +01:00
Victor Gama
c3ac50931e
Implement unit tests for pong method
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
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
7e34e7fd40
Correct the name of the test about proxy 'connect' events.
2014-11-08 16:43:36 +00:00
James Coglan
0bb47c17b4
Remove TLS concerns from the proxy implementation.
...
This results in a more simple design, in the sense of fewer concerns
being mixed together. It makes the API more verbose, but it's not
difficult to use correctly.
It also means that we make the I/O implementation deal with TLS, so it
can use tls.connect({socket: io}) or the upcoming TLSSocket class,
rather than this module needing a huge amount of boilerplate and
internal indirection to use tls.createSecurePair() and make Proxy wrap
pair.encrypted.
Using tls.connect({socket: io}) would be awkward on this end, because it
expects a stream that emits *incoming* data from the TCP connection. All
the streams in this module emit *outgoing* data that should be written
to TCP, so their polarity is flipped compared to what tls.connect()
wants, and resolving that involves even more stream boilerplate.
2014-11-08 15:20:08 +00:00
James Coglan
4348bec390
Some cleanup to remove bits I left lying around while refactoring proxy support.
2014-11-06 23:04:11 +00:00
James Coglan
550b3d906d
Unify the proxy handshake, TLS handshake, and WebSocket protocol into a single stream when using driver.proxy() to simplify the API.
2014-11-05 23:30:15 +00:00
David Glasser
b88b8d6856
proxy should emit 'close' when it's done
...
This will cause any stream piped into it to stop piping into it. (It's
the only way to unpipe a Node 0.8 Streams1-style pipe.)
This change allows you to remove the empty "stream.on('data')" in
faye-websocket.
2014-10-29 16:47:56 -07:00
James Coglan
76f4128634
Redesign the proxy API so that we can more cleanly deal with TLS, either to the proxy server or origin server or both, while still allowing control of the TLS options and custom headers, and not leaking so much of the implementation.
2014-10-29 22:07:01 +00:00
James Coglan
bdc9bfe7e8
Add support for connecting via HTTP proxies.
2014-10-27 09:30:11 +00:00
David Glasser
dcd7c278b6
driver.close() before driver.start() should close
2014-08-15 10:48:30 -07:00
James Coglan
dfe7b2b000
Trailing blank lines are bad.
2014-05-17 00:35:31 +01:00
James Coglan
9f2782da14
Correct the draft-76 status line reason phrase.
2014-04-17 02:23:58 +01:00
David Glasser
f15b331a34
Reduce frame max length to max Node Buffer length.
2013-10-11 19:21:14 -07:00
James Coglan
12f9f4d444
Add support for Basic Auth URLs to the client driver.
2013-08-13 17:16:49 +01:00
James Coglan
c5b3df986b
Migrate to jstest.
2013-07-01 02:10:29 +01:00
James Coglan
1124df2bf5
Add a Server driver for running WebSockets through a bare TCP server.
2013-05-12 01:13:50 +01:00
James Coglan
ea4e289669
Add a setHeader() function to allow peers to add headers to their handshake responses.
2013-05-11 22:26:20 +01:00
James Coglan
d7c65eedd9
Expose the status and headers from the response in the client driver.
2013-05-11 21:58:37 +01:00
James Coglan
25c075a408
Rename the module to websocket-driver.
2013-05-04 16:42:44 +01:00
James Coglan
f16ad50db0
Raise an error if the length header is larger than the max int that JS can represent precisely.
2013-05-04 13:33:27 +01:00
James Coglan
d716650499
Add more robust error handling for Hybi and Client and emit error events when the protocol goes wrong.
2013-05-02 00:09:14 +01:00
James Coglan
103c39c664
Correct the name of a test suite.
2013-05-01 02:11:32 +01:00
James Coglan
23f296b926
Replace the getVersion() method with a version property.
2013-05-01 00:55:49 +01:00
James Coglan
f6481422b9
Firm up the event system. Make handlers only emit their own events, and then map those to Messages and IO events with a bit of glue. Only emit 'data' when streams are readable, same for 'end'.
2013-04-30 23:35:51 +01:00
James Coglan
9975aa089b
Use the Node EventEmitter class to publish events.
2013-04-30 08:20:14 +01:00
James Coglan
b354dd69fa
Implement the draft-76 protocol.
2013-04-29 20:27:35 +01:00
James Coglan
e3b8033c58
Placeholder for draft-76 support just to get the common tests passing.
2013-04-29 08:56:05 +01:00
James Coglan
950cd9f1e2
Implement and test draft-75.
2013-04-29 08:40:05 +01:00
James Coglan
6f7942d5b7
Begin writing the draft75 module.
2013-04-29 07:48:09 +01:00
James Coglan
41ddd82932
Add tests for Hybi and Client handlers and fix some minor bugs.
2013-04-28 23:22:05 +01:00
James Coglan
847bdc1773
Strip the repo down to just the protocol handlers.
2013-04-28 19:04:03 +01:00
James Coglan
62a0c7597f
First steps toward streaming I/O-independent parsing. Implement the Hybi and Client protocol handlers as stateful protcol drivers with two duplex streams, one for messages and one for I/O.
2013-04-28 18:55:58 +01:00
James Coglan
78f8bfb26b
Remove parser specs.
2013-04-28 14:01:28 +01:00
James Coglan
ee22f75959
Remove trailing whitespace.
2012-12-22 23:13:04 +00:00
James Coglan
7b63baa5a6
Fix specs on v0.9.
2012-12-22 23:12:08 +00:00
James Coglan
680d8fc759
Remove an expensive test.
2012-05-21 19:37:40 +01:00