[SoapClient] Fixed typo for proxy options

Fixed #46
This commit is contained in:
Francis Besset 2014-08-18 10:31:20 +02:00
parent 33d641de4e
commit 960c9f557a
3 changed files with 12 additions and 9 deletions

View File

@ -80,6 +80,7 @@ class Curl
if (isset($options['connection_timeout'])) { if (isset($options['connection_timeout'])) {
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']); curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']);
} }
if (isset($options['proxy_host'])) { if (isset($options['proxy_host'])) {
if (false !== $options['proxy_host']) { if (false !== $options['proxy_host']) {
$proxyHost = $options['proxy_host'].(isset($options['proxy_port']) ? $options['proxy_port'] : 8080); $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); 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'])) { 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_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']); curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);

View File

@ -180,14 +180,14 @@ class SoapClientBuilder extends AbstractSoapBuilder
* *
* @return \BeSimple\SoapClient\SoapClientBuilder * @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_host'] = $host;
$this->soapOptions['proxy_port'] = $port; $this->soapOptions['proxy_port'] = $port;
if ($username) { if ($user) {
$this->soapOptions['proxy_login'] = $username; $this->soapOptions['proxy_user'] = $user;
$this->soapOptions['proxy_password'] = $password; $this->soapOptions['proxy_pass'] = $pass;
} }
return $this; return $this;

View File

@ -95,7 +95,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions()); $this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions());
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar'); $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() public function testCreateWithDefaults()