Browse Source

Add error 404 to workerman (#5140)

to have a more realistic approach
Joan Miquel 5 years ago
parent
commit
1620bb7ada

+ 4 - 4
frameworks/PHP/workerman/server-async.php

@@ -70,11 +70,11 @@ $http_worker->onMessage = static function ($connection) {
         //   Http::header('Content-Type: text/plain');
         //   ob_start();
         //   phpinfo();
-        //   $connection->send(ob_get_clean());
+        //   return $connection->send(ob_get_clean());
 
-        //default:
-        //   Http::header('HTTP', true, 404);
-        //   $connection->send('Error 404');
+        default:
+            Http::responseCode(404);
+            $connection->send('Error 404');
     }
 };
 

+ 9 - 9
frameworks/PHP/workerman/server-mysqli.php

@@ -30,15 +30,15 @@ $http_worker->onMessage = static function ($connection) {
             Http::header('Content-Type: application/json');
             return $connection->send(update());
 
-            //case '/info':
-            //   Http::header('Content-Type: text/plain');
-            //   ob_start();
-            //   phpinfo();
-            //   $connection->send(ob_get_clean());
-
-            //default:
-            //   Http::header('HTTP', true, 404);
-            //   $connection->send('Error 404');
+        //case '/info':
+        //   Http::header('Content-Type: text/plain');
+        //   ob_start();
+        //   phpinfo();
+        //   return $connection->send(ob_get_clean());
+
+        default:
+            Http::responseCode(404);
+            $connection->send('Error 404');
     }
 };
 

+ 9 - 9
frameworks/PHP/workerman/server.php

@@ -42,15 +42,15 @@ $http_worker->onMessage = static function ($connection) {
             Http::header('Content-Type: application/json');
             return $connection->send(updateraw());
 
-            //case '/info':
-            //   Http::header('Content-Type: text/plain');
-            //   ob_start();
-            //   phpinfo();
-            //   $connection->send(ob_get_clean());
-
-            //default:
-            //   Http::header('HTTP', true, 404);
-            //   $connection->send('Error 404');
+        //case '/info':
+        //   Http::header('Content-Type: text/plain');
+        //   ob_start();
+        //   phpinfo();
+        //   return $connection->send(ob_get_clean());
+
+        default:
+            Http::responseCode(404);
+            $connection->send('Error 404');
     }
 };