Skip to content

Commit

Permalink
Merge pull request #9285 from ping-yee/8526_curlRequest
Browse files Browse the repository at this point in the history
fix: [CURLRequest] body contains "HTTP/1.0 200 Connection established"
  • Loading branch information
paulbalandan authored Nov 29, 2024
2 parents 72f6a78 + 5e14d16 commit 979ba49
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/system/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.5.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
Expand Down

0 comments on commit 979ba49

Please sign in to comment.