Parcourir la source

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

Fix 400 Bad Request
walkor il y a 2 ans
Parent
commit
4bde503742
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  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;
             }
         }