Commit Graph

32 Commits

Author SHA1 Message Date
James Coglan 2a0ebd9844 Remove an autoload for a nonexistent module. 2017-03-04 12:42:16 +00:00
James Coglan 866aee9319 Add a 'native' option for opting in to using the native parser and unparser. 2017-03-03 22:21:38 +00:00
James Coglan 17749524ec Silence warnings emitted under -W2. 2017-01-11 22:37:52 +00:00
James Coglan 60e4027c59 Extract the parsing/unparsing code from Hybi into Ruby classes that match the C API, drop the Native driver and allow Hybi to take options for which parsers to use. 2017-01-06 09:11:37 +00:00
James Coglan 97b497a520 Drop the old native extension and replace it with the new all-C parser. Replace the old masking code with a Ruby version, so that the Hybi class is pure Ruby. 2016-12-29 01:09:12 +00:00
James Coglan 4e747733a3 Begin wiring the C parser up to a Ruby driver. Driver::Native is currently a hollowed-out copy of Driver::Hybi with the parsing code removed. 2016-12-27 12:26:59 +00:00
James Coglan 9ce857b3d4 Revise uses of encoding APIs.
When originally implemented, we still supported Ruby 1.8, which
necessitated checking for encoding methods and using a regex to validate
UTF-8. These checks are now gone.

We tagged many strings as binary when not strictly necessary, either
because we were just going to iterate their bytes or because we were
going to hand them off to the caller which should just write them
directly to a socket. Strings used as buffers to accumulate streaming
input are still tagged as binary to avoid encoding
collision/conversion.

The places where we do need to tag as UTF-8 (i.e. just before emitting
to the application) remain, but copy the string if necessary. This
allows us to work with frozen strings.

Finally, strings passed in via the Driver#text method should be
*transcoded* to UTF-8 if necessary, not merely tagged. The Ruby
String#encode method produces a new string so this should also be safe
with frozen strings.
2016-05-19 21:08:22 +01:00
James Coglan 4ae198b1d3 Throw a more helpful error if a client driver is created with an invalid URL. 2015-10-17 21:37:13 +01:00
James Coglan 50ca31b4c8 Remove empty Driver#shutdown method. 2015-07-07 20:40:53 +01:00
James Coglan 9523937428 Initialize StreamReader in the base constructor. 2015-07-07 20:38:26 +01:00
Samuel Williams 425e15da83 Use StreamReader for both hybi and draft75. 2015-07-06 10:29:18 +09:00
James Coglan fa11841bfa Don't catch errors from event listeners. Instead, make sure that in all parsing methods in Hybi, @stage is set before any user called is invoked so the parser is in the right state before code that might raise is called. 2015-07-05 18:52:53 +01:00
James Coglan 83d317add2 Rescue from Exception when calling event listeners, and use the name 'error' for caught exceptions. 2015-07-05 15:31:36 +01:00
James Coglan 8eccf044b0 Change stage in the Base.shutdown() method to that all parsers stop processing input. 2015-07-04 21:06:50 +01:00
James Coglan f218999304 If an event listener emits an error, close the connection with code 1011. 2015-07-04 20:54:42 +01:00
James Coglan 7af53b5be0 Add a pong() command for sending unsolicited pong frames. 2015-07-04 18:49:46 +01:00
James Coglan d6b147f2e0 Fail the connection when the server receives an invalid Sec-WebSocket-Extensions header. 2015-03-26 09:43:59 +00:00
James Coglan 7b4352bb2f Throw an error if drivers are created with unrecognised options. 2014-12-17 22:09:58 +00:00
James Coglan eb20069011 Migrate the internal representation of buffers from arrays to ASCII-8BIT strings, since this is what we're planning on handing off to extensions. 2014-12-05 09:17:09 +00:00
James Coglan ef4fc7c57a Migrate the Hybi driver's internals to use Frame and Message objects compatible with websocket-extensions. 2014-12-02 22:51:42 +00:00
James Coglan 0a200bbdef Refactor proxy support into a separate class that represents the proxy connection as a real object. 2014-11-06 23:37:13 +00:00
James Coglan 1b3f32bbc7 Trailing blank lines are bad. 2014-05-17 00:34:48 +01:00
James Coglan 03ca89f4a0 Remove a duplicated request-method check from WebSocket.websocket?. 2014-05-09 00:31:31 +01:00
Steven Williamson 08189c2a30 Minor fixes to allow native gems to load.
- websocket_mask.rb is in lib which in turn then loads websocket_mask.so
  which should reside in the extensions directory external to the gem
  directory at least as of rubygems 2.2.2.

- Changed extensions directory to match gemname as suggested in rubygems
  guide

Simplifies loading the native extension but only tested on ruby 2.1.1
and only in my environment.
2014-04-14 17:18:54 +01:00
James Coglan 13780f7a61 Reduce MAX_LENGTH to 64 MB. 2013-12-27 18:19:09 +00:00
James Coglan 74c4cc1190 Extend max-length checking to draft-{75,76}. 2013-12-20 10:27:48 +00:00
James Coglan ac3bb51cbd Adjust encoding operations so that encoding is explicit at the call site, and all strings written to I/O are ASCII-8BIT. 2013-07-02 09:46:29 +01:00
James Coglan 5a7fadbcbe Add API for setting custom handshake headers. 2013-05-11 20:28:36 +01:00
James Coglan 020c094e96 Add a driver for handling TCP servers, where we don't want to make the user parse the HTTP request. 2013-05-11 19:28:59 +01:00
James Coglan ba696e8e2c Implement a proper streaming HTTP response parser. This makes the client-side parser more robust and also gives a way to building a driver for TCP servers. 2013-05-11 16:56:29 +01:00
James Coglan c5526b1c09 Return false from websocket? unless the request method is GET. 2013-05-04 17:46:35 +01:00
James Coglan be1f1cdc35 Rename the module to websocket-driver. 2013-05-04 16:43:25 +01:00