Bläddra i källkod

Fix `parseHeaders` for request without headers

Fix for case without headers `GET / HTTP 1.1\r\n`
Alex Pavlov 4 år sedan
förälder
incheckning
6b95d8356a
1 ändrade filer med 7 tillägg och 1 borttagningar
  1. 7 1
      Protocols/Http/Request.php

+ 7 - 1
Protocols/Http/Request.php

@@ -392,7 +392,13 @@ class Request
     {
         $this->_data['headers'] = array();
         $raw_head = $this->rawHead();
-        $head_buffer = \substr($raw_head, \strpos($raw_head, "\r\n") + 2);
+        
+        $endFirsLinePosition = \strpos($raw_head, "\r\n");
+        if ($endFirsLinePosition === false) {
+            return;
+        }
+        
+        $head_buffer = \substr($raw_head, $endFirsLinePosition + 2);
         $cacheable = static::$_enableCache && !isset($head_buffer[2048]);
         if ($cacheable && isset(static::$_headerCache[$head_buffer])) {
             $this->_data['headers'] = static::$_headerCache[$head_buffer];