Skip to content

Commit

Permalink
Close connection after Websocket handshake
Browse files Browse the repository at this point in the history
Otherwise we might misinterpret trailing binary data as a second
HTTP request. This happens when we return from the handler with
data still queued up in the socket.
  • Loading branch information
CendioOssman committed Jan 19, 2017
1 parent cb1508f commit 30942f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions websockify/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ def do_websocket_handshake(self):
else:
self.send_header("Sec-WebSocket-Protocol", "binary")
self.end_headers()

# Other requests cannot follow Websocket data
self.close_connection = True

return True
else:
self.send_error(400, "Missing Sec-WebSocket-Version header. Hixie protocols not supported.")
Expand Down

0 comments on commit 30942f1

Please sign in to comment.