Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

Geod24
Copy link
Contributor

@Geod24 Geod24 commented Jul 17, 2016

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 accept const(ubyte)[] - even though it was just forwarding to a const-accepting method.

@Geod24 Geod24 force-pushed the websockets branch 6 times, most recently from 297d620 to 5b3c62f Compare July 19, 2016 02:04
@Geod24
Copy link
Contributor Author

Geod24 commented Jul 19, 2016

Fixed the failures. Now I only get the spurious ones.

@mathias-lang-sociomantic
Copy link
Contributor

Ping @s-ludwig

1 similar comment
@Geod24
Copy link
Contributor Author

Geod24 commented Jul 27, 2016

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)
Copy link
Member

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.
@mathias-lang-sociomantic
Copy link
Contributor

Rebased on master and addressed your comments

Copy link
Member

@s-ludwig s-ludwig left a 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.

s-ludwig pushed a commit that referenced this pull request Jul 11, 2017
s-ludwig pushed a commit that referenced this pull request Jul 12, 2017
@s-ludwig s-ludwig closed this Jul 17, 2017
@mathias-lang-sociomantic
Copy link
Contributor

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).
I should try again to see if everything is fixed now.

@s-ludwig
Copy link
Member

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

@Geod24 Geod24 deleted the websockets branch August 6, 2017 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants