diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index 500b425d2dc5..dfc9ba97f7b2 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -389,7 +389,7 @@ public function send(string $method, string $url) // Set the string we want to break our response from $breakString = "\r\n\r\n"; - if (strpos($output, 'HTTP/1.1 100 Continue') === 0) { + while (strpos($output, 'HTTP/1.1 100 Continue') === 0) { $output = substr($output, strpos($output, $breakString) + 4); } diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index 4893266e5009..3115f86aedbb 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -1109,4 +1109,30 @@ public function testUserAgentOption(): void $this->assertArrayHasKey(CURLOPT_USERAGENT, $options); $this->assertSame($agent, $options[CURLOPT_USERAGENT]); } + + /** + * @see https://github.com/codeigniter4/CodeIgniter4/issues/8347 + */ + public function testMultipleHTTP100(): void + { + $jsonBody = '{"name":"John Doe","age":30}'; + + $output = "HTTP/1.1 100 Continue +Mark bundle as not supporting multiuse +HTTP/1.1 100 Continue +Mark bundle as not supporting multiuse +HTTP/1.1 200 OK +Server: Werkzeug/2.2.2 Python/3.7.17 +Date: Sun, 28 Jan 2024 06:05:36 GMT +Content-Type: application/json +Content-Length: 33\r\n\r\n" . $jsonBody; + + $this->request->setOutput($output); + + $response = $this->request->request('GET', 'http://example.com'); + + $this->assertSame($jsonBody, $response->getBody()); + + $this->assertSame(200, $response->getStatusCode()); + } }