-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websockets: Add a client test again the autobahn testsuite + improvements #1534
Conversation
297d620
to
5b3c62f
Compare
Fixed the failures. Now I only get the spurious ones. |
Ping @s-ludwig |
1 similar comment
Ping @s-ludwig |
@@ -418,7 +425,8 @@ final class WebSocket { | |||
Sends a message using an output stream. | |||
Throws: WebSocketException if the connection is closed. | |||
*/ | |||
void send(scope void delegate(scope OutgoingWebSocketMessage) sender, FrameOpcode frameOpcode = FrameOpcode.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be an additional compatibility wrapper here to avoid breaking code:
/// Compatibility overload - will be removed soon.
deprecated("Need to specify an explicit FrameOpcode.")
void send(scope void delegate(scope OutgoingWebSocketMessage) sender)
{
send(sender, FrameOpcode.text);
}
…st autobahn Autobahn (http://autobahn.ws/testsuite) is a comprehensive test suite of the Websocket specifications. This test won't be run by default as it requires way too much ressources to put it into the CI, but can trivially be run manually by anyone wanting to test the websockets implementation for conformity.
We should not assume what the user is sending, as it varies from one application to another. The default might as well be binary and would seem more sensible to some.
Reduce the need for additional buffer, opening the way for more memory improvements, and document what it is doing. Also corrects a bug with length == 65536, as it would be cast to `ushort` which maximum size is 65535. Finally, fixup documentation and type of FrameOpcode.
Reduce number of static buffers (3 -> 1) Comment the internals Only demask when the frame is masked (the previous code didn't yield incorrect data, but needlessly iterated and assigned data to an array) Check that the most significant bit of the 8 bytes length is 0.
Rebased on master and addressed your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally also got around to review this and all looks good. The only issue is that I accidentally made an overlapping change in the frame writing code. I'll manually rebase this and skip 4afc22b, which more or less does the same.
Oh, thank you very much ! Sorry this went off the radar a bit, I don't actively work on that project currently, since I had many issues (notably the fact that the bot would only survive a minute). |
Good that you mentioned it again! I actually remembered that I observed the same issue in one of my projects (it does an auto-reconnect anyway, so it didn't seem so important) and now pushed a fix for this: #1848 |
Here's a couple of improvements to the Websockets implementation.
First, a new 'test', which is not run by default, against the autobahn testsuite (see #1505 ).
Currently, it passes 517 out of 519 test cases (it blocks on the 518th, haven't investigated yet).
The other improvements are mostly cosmetic / performance: reduce the size of the
Frame
, document everything, provide a better encapsulation...There's a change to the API, where 'send' with a message doesn't assume the data to be text anymore, and
send
didn't acceptconst(ubyte)[]
- even though it was just forwarding to a const-accepting method.