From 00ed1d28178a5b25e4935243de0bfc2627b16523 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 21 Mar 2019 13:43:47 -0700 Subject: [PATCH] HTTP/1.1 response should contains a reason (websocket server) Fix compatibility problem with websockets python library, where the response does not contains a reason File "/.../lib/python3.7/site-packages/websockets/http.py", line 126, in read_response version, status_code, reason = status_line[:-2].split(b' ', 2) ValueError: not enough values to unpack (expected 3, got 2) The above exception was the direct cause of the following exception: websockets.exceptions.InvalidMessage: Malformed HTTP message --- ixwebsocket/IXWebSocketHandshake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ixwebsocket/IXWebSocketHandshake.cpp b/ixwebsocket/IXWebSocketHandshake.cpp index 8193892f..403aac6f 100644 --- a/ixwebsocket/IXWebSocketHandshake.cpp +++ b/ixwebsocket/IXWebSocketHandshake.cpp @@ -353,7 +353,7 @@ namespace ix WebSocketHandshakeKeyGen::generate(headers["sec-websocket-key"].c_str(), output); std::stringstream ss; - ss << "HTTP/1.1 101\r\n"; + ss << "HTTP/1.1 101 Switching Protocols\r\n"; ss << "Sec-WebSocket-Accept: " << std::string(output) << "\r\n"; ss << "Upgrade: websocket\r\n"; ss << "Connection: Upgrade\r\n";