diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index 9da231c17716..90157e4e05d4 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -389,7 +389,7 @@ public function send(string $method, string $url) $output = substr($output, strpos($output, $breakString) + 4); } - if (str_starts_with($output, 'HTTP/1.1 200 Connection established')) { + if (preg_match('/HTTP\/\d\.\d 200 Connection established/i', $output)) { $output = substr($output, strpos($output, $breakString) + 4); } diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index f14198be2264..df44c427a665 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -831,6 +831,21 @@ public function testSendProxied(): void $this->assertSame('Hi there', $response->getBody()); } + public function testSendProxiedWithHTTP10(): void + { + $request = $this->getRequest([ + 'base_uri' => 'http://www.foo.com/api/v1/', + 'delay' => 100, + ]); + + $output = "HTTP/1.0 200 Connection established +Proxy-Agent: Fortinet-Proxy/1.0\x0d\x0a\x0d\x0aHTTP/1.1 200 OK\x0d\x0a\x0d\x0aHi there"; + $request->setOutput($output); + + $response = $request->get('answer'); + $this->assertSame('Hi there', $response->getBody()); + } + /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394 */