Skip to content

Commit 229427a

Browse files
authored
Merge pull request #7622 from jozefrebjak/fix-curlrequest-http-proxy
fix: skip http proxy added header
2 parents af377af + a20365b commit 229427a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

system/HTTP/CURLRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ public function send(string $method, string $url)
387387
$output = substr($output, strpos($output, $breakString) + 4);
388388
}
389389

390+
if (strpos($output, 'HTTP/1.1 200 Connection established') === 0) {
391+
$output = substr($output, strpos($output, $breakString) + 4);
392+
}
393+
390394
// If request and response have Digest
391395
if (isset($this->config['auth'][2]) && $this->config['auth'][2] === 'digest' && strpos($output, 'WWW-Authenticate: Digest') !== false) {
392396
$output = substr($output, strpos($output, $breakString) + 4);

tests/system/HTTP/CURLRequestTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,21 @@ public function testSendContinuedWithManyHeaders()
765765
$this->assertSame(200, $response->getStatusCode());
766766
}
767767

768+
public function testSendProxied()
769+
{
770+
$request = $this->getRequest([
771+
'base_uri' => 'http://www.foo.com/api/v1/',
772+
'delay' => 100,
773+
]);
774+
775+
$output = "HTTP/1.1 200 Connection established
776+
Proxy-Agent: Fortinet-Proxy/1.0\x0d\x0a\x0d\x0aHTTP/1.1 200 OK\x0d\x0a\x0d\x0aHi there";
777+
$request->setOutput($output);
778+
779+
$response = $request->get('answer');
780+
$this->assertSame('Hi there', $response->getBody());
781+
}
782+
768783
/**
769784
* See: https://github.com/codeigniter4/CodeIgniter4/issues/7394
770785
*/

0 commit comments

Comments
 (0)