From 55c39987471f11535f84c46ddb737de7a72fa345 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Mon, 18 Nov 2024 16:55:29 +0800 Subject: [PATCH 1/2] fix: extend the curl header handle. --- system/HTTP/CURLRequest.php | 2 +- tests/system/HTTP/CURLRequestTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 */ From 5e14d16616d216e0eac866f60c522753327fef90 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Thu, 28 Nov 2024 20:57:31 +0800 Subject: [PATCH 2/2] docs: add the change log. --- user_guide_src/source/changelogs/v4.5.6.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelogs/v4.5.6.rst b/user_guide_src/source/changelogs/v4.5.6.rst index 75d4d92212b6..1dbaf55f2482 100644 --- a/user_guide_src/source/changelogs/v4.5.6.rst +++ b/user_guide_src/source/changelogs/v4.5.6.rst @@ -40,6 +40,7 @@ Bugs Fixed - **Routing:** Fixed a TypeError in `str_replace()` when `Routing::$translateURIDashes` is set to `true` and a route is defined using a closure. - **Validation:** Fixed a bug where complex language strings were not properly handled. +- **CURLRequest:** Added support for handling proxy responses using HTTP versions other than 1.1. See the repo's `CHANGELOG.md `_