Support 0xFF frames and closing handshakes #9
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).