Support 0xFF frames and closing handshakes#9
Open
wulczer wants to merge 4 commits intorlotun:masterfrom
Open
Conversation
Support 0xFF frames, as specified in the WebSocket protocol draft hixie-76, section 5.3. Introduce a separate instance variable controlling the maximum size of a 0xFF frame that the server will accept.
Specified in section 1.4 of hixie-76, the closing handshake can be initiated by either peer. Support closing handshakes initiated by the client, the server does not have the ability to initiate closing handshakes himself.
Otherwise the frameLengthExceeded handler can be called multiple times while decoding the length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As specified in http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76#section-4.2 WebSocket frames can also be of type 0xFF, with a length specification followed by arbitrary data, that the server should discard. The first commit implements parsing this type of frames. The parsing process has been overhauled by using twisted.web._newclient.makeStatefulDispatch, so it introduces a dependency on Twisted 9.0.0 (I hope it's OK, if not it's easy to do the dispatch by hand).
The second commit implements the closing handshake that can be initiated by the client, as described in http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76#section-1.4. Without this, closing the browser while it's connected to the WebSocket server results in a traceback in the server log (this happens both with Chrome and Firefox native WebSockets and with web-socket-js).