Skip to content

Commit

Permalink
HTTP protocol access to WebSocket returns a 400 error.
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed Jul 4, 2024
1 parent 4b35b7e commit 405d904
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Protocols/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<div style=\"text-align:center\"><h1>WebSocket</h1><hr>workerman/" . Worker::VERSION . "</div>",
true);
$connection->close("HTTP/1.0 400 Bad Request\r\nServer: workerman\r\n\r\n<div style=\"text-align:center\"><h1>WebSocket</h1><hr>workerman</div>", true);
return 0;
}
// Calculation websocket key.
Expand Down Expand Up @@ -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<div style=\"text-align:center\"><h1>WebSocket</h1><hr>workerman/" . Worker::VERSION . "</div>",
true);
$connection->close("HTTP/1.0 400 Bad Request\r\nServer: workerman\r\n\r\n<div style=\"text-align:center\"><h1>400 Bad Request</h1><hr>workerman</div>", true);
return 0;
}

Expand Down

0 comments on commit 405d904

Please sign in to comment.