瀏覽代碼

Merge pull request #922 from joanhey/fix-400-bad-request

Fix 400 Bad Request
walkor 2 年之前
父節點
當前提交
4bde503742
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/Protocols/Http.php

+ 3 - 3
src/Protocols/Http.php

@@ -118,7 +118,7 @@ class Http
         $firstLine = explode(" ", strstr($buffer, "\r\n", true), 3);
 
         if (!in_array($firstLine[0], ['GET', 'POST', 'OPTIONS', 'HEAD', 'DELETE', 'PUT', 'PATCH'])) {
-            $connection->close("HTTP/1.1 400 Bad Request\r\n\r\n", true);
+            $connection->close("HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n", true);
             return 0;
         }
 
@@ -126,7 +126,7 @@ class Http
         $hostHeaderPosition = stripos($header, "\r\nHost: ");
 
         if (false === $hostHeaderPosition && $firstLine[2] === "HTTP/1.1") {
-            $connection->close("HTTP/1.1 400 Bad Request\r\n\r\n", true);
+            $connection->close("HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n", true);
             return 0;
         }
 
@@ -139,7 +139,7 @@ class Http
         } else {
             $hasContentLength = false;
             if (false !== stripos($header, "\r\nTransfer-Encoding:")) {
-                $connection->close("HTTP/1.1 400 Bad Request\r\n\r\n", true);
+                $connection->close("HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n", true);
                 return 0;
             }
         }