From 405d904d33026e19497dffc3d085bbc16e66534e Mon Sep 17 00:00:00 2001 From: walkor Date: Thu, 4 Jul 2024 16:26:39 +0800 Subject: [PATCH] HTTP protocol access to WebSocket returns a 400 error. --- Protocols/Websocket.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Protocols/Websocket.php b/Protocols/Websocket.php index 0f94de613..743e962b7 100644 --- a/Protocols/Websocket.php +++ b/Protocols/Websocket.php @@ -420,8 +420,7 @@ public static function dealHandshake($buffer, $connection) if (\preg_match("/Sec-WebSocket-Key: *(.*?)\r\n/i", $buffer, $match)) { $Sec_WebSocket_Key = $match[1]; } else { - $connection->close("HTTP/1.1 200 WebSocket\r\nServer: workerman/" . Worker::VERSION . "\r\n\r\n

WebSocket


workerman/" . Worker::VERSION . "
", - true); + $connection->close("HTTP/1.0 400 Bad Request\r\nServer: workerman\r\n\r\n

WebSocket


workerman
", true); return 0; } // Calculation websocket key. @@ -501,8 +500,7 @@ public static function dealHandshake($buffer, $connection) return 0; } // Bad websocket handshake request. - $connection->close("HTTP/1.1 200 WebSocket\r\nServer: workerman/" . Worker::VERSION . "\r\n\r\n

WebSocket


workerman/" . Worker::VERSION . "
", - true); + $connection->close("HTTP/1.0 400 Bad Request\r\nServer: workerman\r\n\r\n

400 Bad Request


workerman
", true); return 0; }