Skip to content

Commit 979ba49

Browse files
authored
Merge pull request #9285 from ping-yee/8526_curlRequest
fix: [CURLRequest] body contains "HTTP/1.0 200 Connection established"
2 parents 72f6a78 + 5e14d16 commit 979ba49

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

system/HTTP/CURLRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function send(string $method, string $url)
389389
$output = substr($output, strpos($output, $breakString) + 4);
390390
}
391391

392-
if (str_starts_with($output, 'HTTP/1.1 200 Connection established')) {
392+
if (preg_match('/HTTP\/\d\.\d 200 Connection established/i', $output)) {
393393
$output = substr($output, strpos($output, $breakString) + 4);
394394
}
395395

tests/system/HTTP/CURLRequestTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,21 @@ public function testSendProxied(): void
831831
$this->assertSame('Hi there', $response->getBody());
832832
}
833833

834+
public function testSendProxiedWithHTTP10(): void
835+
{
836+
$request = $this->getRequest([
837+
'base_uri' => 'http://www.foo.com/api/v1/',
838+
'delay' => 100,
839+
]);
840+
841+
$output = "HTTP/1.0 200 Connection established
842+
Proxy-Agent: Fortinet-Proxy/1.0\x0d\x0a\x0d\x0aHTTP/1.1 200 OK\x0d\x0a\x0d\x0aHi there";
843+
$request->setOutput($output);
844+
845+
$response = $request->get('answer');
846+
$this->assertSame('Hi there', $response->getBody());
847+
}
848+
834849
/**
835850
* See: https://github.com/codeigniter4/CodeIgniter4/issues/7394
836851
*/

user_guide_src/source/changelogs/v4.5.6.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Bugs Fixed
4040
- **Routing:** Fixed a TypeError in `str_replace()` when `Routing::$translateURIDashes` is set to `true` and a route is defined using a closure.
4141

4242
- **Validation:** Fixed a bug where complex language strings were not properly handled.
43+
- **CURLRequest:** Added support for handling proxy responses using HTTP versions other than 1.1.
4344

4445
See the repo's
4546
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)