[SoapClient] Add possiblity to disable proxy if present in environment variable
This commit is contained in:
parent
b3c6353af8
commit
c24e8775bf
|
@ -81,8 +81,13 @@ class Curl
|
|||
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']);
|
||||
}
|
||||
if (isset($options['proxy_host'])) {
|
||||
$port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080;
|
||||
curl_setopt($this->ch, CURLOPT_PROXY, $options['proxy_host'] . ':' . $port);
|
||||
if (false !== $options['proxy_host']) {
|
||||
$proxyHost = $options['proxy_host'].(isset($options['proxy_port']) ? $options['proxy_port'] : 8080);
|
||||
} else {
|
||||
$proxyHost = false;
|
||||
}
|
||||
|
||||
curl_setopt($this->ch, CURLOPT_PROXY, $proxyHost);
|
||||
}
|
||||
if (isset($options['proxy_user'])) {
|
||||
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
|
||||
|
@ -310,4 +315,4 @@ class Curl
|
|||
|
||||
return trim(array_pop($matches));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ class CurlTest extends AbstractWebserverTest
|
|||
{
|
||||
public function testExec()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)));
|
||||
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)));
|
||||
|
@ -29,7 +31,9 @@ class CurlTest extends AbstractWebserverTest
|
|||
|
||||
public function testGetErrorMessage()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$curl->exec('http://unknown/curl.txt');
|
||||
$this->assertEquals('Could not connect to host', $curl->getErrorMessage());
|
||||
|
@ -43,7 +47,9 @@ class CurlTest extends AbstractWebserverTest
|
|||
|
||||
public function testGetRequestHeaders()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||
$this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders()));
|
||||
|
@ -54,7 +60,9 @@ class CurlTest extends AbstractWebserverTest
|
|||
|
||||
public function testGetResponse()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||
$this->assertSame('OK', $curl->getResponseStatusMessage());
|
||||
|
|
|
@ -41,7 +41,9 @@ class WsdlDownloaderTest extends AbstractWebserverTest
|
|||
Cache::setDirectory($wsdlCacheUrl);
|
||||
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
||||
|
||||
$wsdlDownloader = new WsdlDownloader(new Curl());
|
||||
$wsdlDownloader = new WsdlDownloader(new Curl(array(
|
||||
'proxy_host' => false,
|
||||
)));
|
||||
$this->assertCount(0, $wsdlCacheDir->getChildren());
|
||||
|
||||
$cacheFileName = $wsdlDownloader->download($source);
|
||||
|
|
Loading…
Reference in New Issue