mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
feat: add request option proxy
This commit is contained in:
parent
d19d0342a6
commit
8c6e883383
@ -550,6 +550,12 @@ class CURLRequest extends OutgoingRequest
|
||||
}
|
||||
}
|
||||
|
||||
// Proxy
|
||||
if (isset($config['proxy'])) {
|
||||
$curlOptions[CURLOPT_HTTPPROXYTUNNEL] = true;
|
||||
$curlOptions[CURLOPT_PROXY] = $config['proxy'];
|
||||
}
|
||||
|
||||
// Debug
|
||||
if ($config['debug']) {
|
||||
$curlOptions[CURLOPT_VERBOSE] = 1;
|
||||
|
@ -559,6 +559,20 @@ final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function testProxyuOption()
|
||||
{
|
||||
$this->request->request('get', 'http://example.com', [
|
||||
'proxy' => 'http://localhost:3128',
|
||||
]);
|
||||
|
||||
$options = $this->request->curl_options;
|
||||
|
||||
$this->assertArrayHasKey(CURLOPT_PROXY, $options);
|
||||
$this->assertSame('http://localhost:3128', $options[CURLOPT_PROXY]);
|
||||
$this->assertArrayHasKey(CURLOPT_HTTPPROXYTUNNEL, $options);
|
||||
$this->assertTrue($options[CURLOPT_HTTPPROXYTUNNEL]);
|
||||
}
|
||||
|
||||
public function testDebugOptionTrue()
|
||||
{
|
||||
$this->request->request('get', 'http://example.com', [
|
||||
|
@ -542,6 +542,20 @@ final class CURLRequestTest extends CIUnitTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function testProxyuOption()
|
||||
{
|
||||
$this->request->request('get', 'http://example.com', [
|
||||
'proxy' => 'http://localhost:3128',
|
||||
]);
|
||||
|
||||
$options = $this->request->curl_options;
|
||||
|
||||
$this->assertArrayHasKey(CURLOPT_PROXY, $options);
|
||||
$this->assertSame('http://localhost:3128', $options[CURLOPT_PROXY]);
|
||||
$this->assertArrayHasKey(CURLOPT_HTTPPROXYTUNNEL, $options);
|
||||
$this->assertTrue($options[CURLOPT_HTTPPROXYTUNNEL]);
|
||||
}
|
||||
|
||||
public function testDebugOptionTrue()
|
||||
{
|
||||
$this->request->request('get', 'http://example.com', [
|
||||
|
Loading…
x
Reference in New Issue
Block a user