diff --git a/src/BeSimple/SoapClient/Curl.php b/src/BeSimple/SoapClient/Curl.php index d33efed..8bc814b 100644 --- a/src/BeSimple/SoapClient/Curl.php +++ b/src/BeSimple/SoapClient/Curl.php @@ -80,6 +80,7 @@ class Curl if (isset($options['connection_timeout'])) { curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']); } + if (isset($options['proxy_host'])) { if (false !== $options['proxy_host']) { $proxyHost = $options['proxy_host'].(isset($options['proxy_port']) ? $options['proxy_port'] : 8080); @@ -88,10 +89,12 @@ class Curl } curl_setopt($this->ch, CURLOPT_PROXY, $proxyHost); + + if ($proxyHost && isset($options['proxy_user'])) { + curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'].':'.$options['proxy_pass']); + } } - if (isset($options['proxy_user'])) { - curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']); - } + if (isset($options['login'])) { curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY); curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']); diff --git a/src/BeSimple/SoapClient/SoapClientBuilder.php b/src/BeSimple/SoapClient/SoapClientBuilder.php index cce4a9a..a01463f 100644 --- a/src/BeSimple/SoapClient/SoapClientBuilder.php +++ b/src/BeSimple/SoapClient/SoapClientBuilder.php @@ -180,14 +180,14 @@ class SoapClientBuilder extends AbstractSoapBuilder * * @return \BeSimple\SoapClient\SoapClientBuilder */ - public function withProxy($host, $port, $username = null, $password = null) + public function withProxy($host, $port, $user = null, $pass = null) { $this->soapOptions['proxy_host'] = $host; $this->soapOptions['proxy_port'] = $port; - if ($username) { - $this->soapOptions['proxy_login'] = $username; - $this->soapOptions['proxy_password'] = $password; + if ($user) { + $this->soapOptions['proxy_user'] = $user; + $this->soapOptions['proxy_pass'] = $pass; } return $this; @@ -236,4 +236,4 @@ class SoapClientBuilder extends AbstractSoapBuilder { $this->validateWsdl(); } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php b/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php index a0ebfeb..271f390 100644 --- a/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php +++ b/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php @@ -95,7 +95,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions()); $builder->withProxy('127.0.0.1', 8585, 'foo', 'bar'); - $this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions()); + $this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_user' => 'foo', 'proxy_pass' => 'bar')), $builder->getSoapOptions()); } public function testCreateWithDefaults()