Explorar o código

http header of server

walkor %!s(int64=9) %!d(string=hai) anos
pai
achega
9587d200a1
Modificáronse 2 ficheiros con 5 adicións e 3 borrados
  1. 3 2
      Protocols/Http.php
  2. 2 1
      Protocols/Websocket.php

+ 3 - 2
Protocols/Http.php

@@ -14,6 +14,7 @@
 namespace Workerman\Protocols;
 
 use Workerman\Connection\TcpConnection;
+use Workerman\Worker;
 
 /**
  * http protocol
@@ -77,7 +78,7 @@ class Http
             'REQUEST_METHOD'       => '',
             'REQUEST_URI'          => '',
             'SERVER_PROTOCOL'      => '',
-            'SERVER_SOFTWARE'      => 'workerman/3.3.3',
+            'SERVER_SOFTWARE'      => 'workerman/'.Worker::VERSION,
             'SERVER_NAME'          => '',
             'HTTP_HOST'            => '',
             'HTTP_USER_AGENT'      => '',
@@ -200,7 +201,7 @@ class Http
         }
 
         // header
-        $header .= "Server: WorkerMan/3.0\r\nContent-Length: " . strlen($content) . "\r\n\r\n";
+        $header .= "Server: workerman/" . Worker::VERSION . "\r\nContent-Length: " . strlen($content) . "\r\n\r\n";
 
         // save session
         self::sessionWriteClose();

+ 2 - 1
Protocols/Websocket.php

@@ -321,6 +321,7 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
             $handshake_message .= "Upgrade: websocket\r\n";
             $handshake_message .= "Sec-WebSocket-Version: 13\r\n";
             $handshake_message .= "Connection: Upgrade\r\n";
+            $handshake_message .= "Server: workerman/".Worker::VERSION."\r\n";
             $handshake_message .= "Sec-WebSocket-Accept: " . $new_key . "\r\n\r\n";
             // Mark handshake complete..
             $connection->websocketHandshake = true;
@@ -356,7 +357,7 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
                     Worker::log($e);
                     exit(250);
                 }
-                if ($_SESSION && class_exists('\GatewayWorker\Lib\Context')) {
+                if (!empty($_SESSION) && class_exists('\GatewayWorker\Lib\Context')) {
                     $connection->session = \GatewayWorker\Lib\Context::sessionEncode($_SESSION);
                 }
                 $_GET = $_SERVER = $_SESSION = $_COOKIE = array();