Parcourir la source

HTTP protocol access to WebSocket returns a 400 error.

walkor il y a 1 an
Parent
commit
259aab0f07
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      src/Protocols/Websocket.php

+ 3 - 3
src/Protocols/Websocket.php

@@ -362,7 +362,7 @@ class Websocket
                 $SecWebSocketKey = $match[1];
             } else {
                 $connection->close(
-                    "HTTP/1.0 200 OK\r\nServer: workerman\r\n\r\n<div style=\"text-align:center\"><h1>WebSocket</h1><hr>workerman</div>", true);
+                    "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.
@@ -414,7 +414,7 @@ class Websocket
             $handshakeMessage .= "\r\n";
             // Send handshake response.
             $connection->send($handshakeMessage, true);
-            // Mark handshake complete..
+            // Mark handshake complete.
             $connection->context->websocketHandshake = true;
 
             // There are data waiting to be sent.
@@ -429,7 +429,7 @@ class Websocket
         }
         // Bad websocket handshake request.
         $connection->close(
-            "HTTP/1.0 200 OK\r\nServer: workerman\r\n\r\n<div style=\"text-align:center\"><h1>WebSocket</h1><hr>workerman</div>", true);
+            "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;
     }
 }