feat: add request option proxy

This commit is contained in:
kenjis 2023-06-28 09:29:26 +09:00
parent d19d0342a6
commit 8c6e883383
No known key found for this signature in database
GPG Key ID: BD254878922AF198
3 changed files with 34 additions and 0 deletions

View File

@ -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;

View File

@ -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', [

View File

@ -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', [