Skip to content

Commit 960c9f5

Browse files
committed
[SoapClient] Fixed typo for proxy options
Fixed BeSimple#46
1 parent 33d641d commit 960c9f5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/BeSimple/SoapClient/Curl.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function __construct(array $options = array(), $followLocationMaxRedirect
8080
if (isset($options['connection_timeout'])) {
8181
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']);
8282
}
83+
8384
if (isset($options['proxy_host'])) {
8485
if (false !== $options['proxy_host']) {
8586
$proxyHost = $options['proxy_host'].(isset($options['proxy_port']) ? $options['proxy_port'] : 8080);
@@ -88,10 +89,12 @@ public function __construct(array $options = array(), $followLocationMaxRedirect
8889
}
8990

9091
curl_setopt($this->ch, CURLOPT_PROXY, $proxyHost);
92+
93+
if ($proxyHost && isset($options['proxy_user'])) {
94+
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'].':'.$options['proxy_pass']);
95+
}
9196
}
92-
if (isset($options['proxy_user'])) {
93-
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
94-
}
97+
9598
if (isset($options['login'])) {
9699
curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
97100
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);

src/BeSimple/SoapClient/SoapClientBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ public function withDigestAuthentication($certificate, $passphrase = null)
180180
*
181181
* @return \BeSimple\SoapClient\SoapClientBuilder
182182
*/
183-
public function withProxy($host, $port, $username = null, $password = null)
183+
public function withProxy($host, $port, $user = null, $pass = null)
184184
{
185185
$this->soapOptions['proxy_host'] = $host;
186186
$this->soapOptions['proxy_port'] = $port;
187187

188-
if ($username) {
189-
$this->soapOptions['proxy_login'] = $username;
190-
$this->soapOptions['proxy_password'] = $password;
188+
if ($user) {
189+
$this->soapOptions['proxy_user'] = $user;
190+
$this->soapOptions['proxy_pass'] = $pass;
191191
}
192192

193193
return $this;
@@ -236,4 +236,4 @@ protected function validateOptions()
236236
{
237237
$this->validateWsdl();
238238
}
239-
}
239+
}

src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testWithProxy()
9595
$this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions());
9696

9797
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar');
98-
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions());
98+
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_user' => 'foo', 'proxy_pass' => 'bar')), $builder->getSoapOptions());
9999
}
100100

101101
public function testCreateWithDefaults()

0 commit comments

Comments
 (0)