Close connection after Websocket handshake

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.
This commit is contained in:
Pierre Ossman 2017-01-19 14:53:15 +01:00
parent cb1508fa49
commit 30942f12d3
1 changed files with 4 additions and 0 deletions

View File

@ -467,6 +467,10 @@ class WebSocketRequestHandler(SimpleHTTPRequestHandler):
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.")