Requests without an Origin header previously caused an exception to be thrown if the allowed origins passed to the constructor was set to a dynamic function. Omitted origins are now set to an asterisk and passed properly to the origins function.
A test for this case is included in this commit.
On server, `.of(name)` should use the same key in `.nsps` object for "" and "/"
Important to use `String(name)` and `===` to keep out keys that don't cast to ""
Source of bug: after connection to nsp '/', the socket's connectBuffer
was being deleted. On attempt to reconnect to a different namespace,
the connect buffer was deleted and we attempted to push to it. Instead
of the deleting the connect buffer, it is now emptied.
lib/namespace.js previously was not considering whether an event had
binary data and was giving all events parser.EVENT type -- now it uses
the has-binary-data module to set the event type appropriately.
Then, after this fix there was a problem with lib/adapter.js -- because
socket.io-parser modifies the packet object in its encoding, the sockets
after the 1st in a broadcast were not getting the correct data. To fix
this, the data is encoded once in adapter, and then the encoded data
is passed to each of the sockets.
lib/socket.js and lib/client.js were updated to allow for the above. The
.packet method of each now takes an optional second "preEncoded" parameter
-- if this is true, then client skips the encoding and just writes the
packet argument directly to engine.
test/socket.io.js was updated to add two new tests that test
multi-messaging of events with binary data.
Socket.io-parser now has a class-based Encoder and Decoder scheme,
so client.js was changed appropriately.
The main difference is that most of the logic for interpreting packets
is now isolated to parser, and client receives a 'decoded' event when
parser has a reconstructed packet ready to go.
This is a squash of four boring commits. The gist is that client.js
encoding and decoding stuff was updated to take an array of encoded packets
to write, and to handle sequences of binary packets to decode. There was
also merging done with upstream. All tests are passing.
This is a squash of about 25 commits, and here is a summary:
adamreis added initial binary test with the doge image.
kevin-roark updated binary tests and wrote some binary encoding protocol.
kevin-roark replaced the custom binary encoding with msgpack because we
have to handle arbitrary json that contains binary.
adamreis added some 'crazy' tests for emmiting and receiving events with
several types of data.
kevin-roark updated client.js to use socket.io-protocol's async encoding
Did a bunch of upstream merging.