Skip to content

Commit 91e91c4

Browse files
committed
Merge branch '0.2'
2 parents 102e4cf + 50f186f commit 91e91c4

14 files changed

Lines changed: 73 additions & 22 deletions

Curl.php

Lines changed: 10 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,16 @@ public function __construct(array $options = array(), $followLocationMaxRedirect
8889
}
8990

9091
curl_setopt($this->ch, CURLOPT_PROXY, $proxyHost);
92+
93+
if (false !== $proxyHost && isset($options['proxy_login'])) {
94+
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_login'].':'.$options['proxy_password']);
95+
96+
if (isset($options['proxy_auth'])) {
97+
curl_setopt($this->ch, CURLOPT_PROXYAUTH, $options['proxy_auth']);
98+
}
99+
}
91100
}
92-
if (isset($options['proxy_user'])) {
93-
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
94-
}
101+
95102
if (isset($options['login'])) {
96103
curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
97104
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);

SoapClientBuilder.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,28 @@ public function withDigestAuthentication($certificate, $passphrase = null)
175175
*
176176
* @param string $host Host
177177
* @param int $port Port
178-
* @param string $username Username
178+
* @param string $login Login
179179
* @param string $password Password
180+
* @param int $auth Authentication method
180181
*
181182
* @return \BeSimple\SoapClient\SoapClientBuilder
182183
*/
183-
public function withProxy($host, $port, $username = null, $password = null)
184+
public function withProxy($host, $port, $login = null, $password = null, $auth = null)
184185
{
185186
$this->soapOptions['proxy_host'] = $host;
186187
$this->soapOptions['proxy_port'] = $port;
187188

188-
if ($username) {
189-
$this->soapOptions['proxy_login'] = $username;
189+
if ($login) {
190+
$this->soapOptions['proxy_login'] = $login;
190191
$this->soapOptions['proxy_password'] = $password;
192+
193+
if ($auth) {
194+
if (!in_array($auth, array(\CURLAUTH_BASIC, \CURLAUTH_NTLM), true)) {
195+
throw new \InvalidArgumentException('Invalid authentication method: CURLAUTH_BASIC or CURLAUTH_NTLM constants are availables.');
196+
}
197+
198+
$this->soapOptions['proxy_auth'] = $auth;
199+
}
191200
}
192201

193202
return $this;
@@ -236,4 +245,4 @@ protected function validateOptions()
236245
{
237246
$this->validateWsdl();
238247
}
239-
}
248+
}

Tests/AxisInterop/MtomAxisInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MtomAxisInteropTest extends TestCase
2828
'base64Binary' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary',
2929
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest',
3030
),
31+
'proxy_host' => false,
3132
);
3233

3334
public function testAttachment()
@@ -48,4 +49,4 @@ public function testAttachment()
4849
// $this->assertEquals($b64->_, file_get_contents($fileCreatedByServer));
4950
// unlink($fileCreatedByServer);
5051
}
51-
}
52+
}

Tests/AxisInterop/SwaAxisInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SwaAxisInteropTest extends TestCase
3737
'uploadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile',
3838
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse',
3939
),
40+
'proxy_host' => false,
4041
);
4142

4243
public function testUploadDownloadText()
@@ -74,4 +75,4 @@ public function testUploadDownloadImage()
7475

7576
$this->assertEquals($upload->data, $result->data);
7677
}
77-
}
78+
}

Tests/AxisInterop/WsAddressingAxisInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class WsAddressingAxisInteropTest extends TestCase
3232
private $options = array(
3333
'soap_version' => SOAP_1_2,
3434
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
35+
'proxy_host' => false,
3536
);
3637

3738
public function testSession()
@@ -56,4 +57,4 @@ public function testSession()
5657

5758
$this->assertEquals($soapSessionId1, $soapSessionId2);
5859
}
59-
}
60+
}

Tests/AxisInterop/WsSecuritySigEncAxisInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class WsSecuritySigEncAxisInteropTest extends TestCase
6464
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
6565
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
6666
),
67+
'proxy_host' => false,
6768
);
6869

6970
public function testSigEnc()
@@ -103,4 +104,4 @@ public function testSigEnc()
103104

104105
// getBooksByType("scifi");
105106
}
106-
}
107+
}

Tests/AxisInterop/WsSecurityUserPassAxisInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class WsSecurityUserPassAxisInteropTest extends TestCase
4040
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
4141
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
4242
),
43+
'proxy_host' => false,
4344
);
4445

4546
public function testUserPassText()
@@ -93,4 +94,4 @@ public function testUserPassDigest()
9394

9495
// getBooksByType("scifi");
9596
}
96-
}
97+
}

Tests/CurlTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ public function testGetResponse()
7474

7575
public function testGetResponseBody()
7676
{
77-
$curl = new Curl();
77+
$curl = new Curl(array(
78+
'proxy_host' => false,
79+
));
7880

7981
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
8082
$this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody());
8183
}
8284

8385
public function testGetResponseContentType()
8486
{
85-
$curl = new Curl();
87+
$curl = new Curl(array(
88+
'proxy_host' => false,
89+
));
8690

8791
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
8892
$this->assertEquals('text/plain; charset=UTF-8', $curl->getResponseContentType());
@@ -93,7 +97,9 @@ public function testGetResponseContentType()
9397

9498
public function testGetResponseHeaders()
9599
{
96-
$curl = new Curl();
100+
$curl = new Curl(array(
101+
'proxy_host' => false,
102+
));
97103

98104
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
99105
$this->assertEquals(117 + self::$websererPortLength, strlen($curl->getResponseHeaders()));
@@ -104,7 +110,9 @@ public function testGetResponseHeaders()
104110

105111
public function testGetResponseStatusCode()
106112
{
107-
$curl = new Curl();
113+
$curl = new Curl(array(
114+
'proxy_host' => false,
115+
));
108116

109117
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
110118
$this->assertEquals(200, $curl->getResponseStatusCode());

Tests/ServerInterop/MtomServerInteropTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class MtomServerInteropTest extends TestCase
2020
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
2121
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
2222
),
23+
'proxy_host' => false,
2324
);
2425

2526
public function testAttachment()
@@ -40,4 +41,4 @@ public function testAttachment()
4041
$this->assertEquals($b64->_, file_get_contents($fileCreatedByServer));
4142
unlink($fileCreatedByServer);
4243
}
43-
}
44+
}

Tests/ServerInterop/SwaServerInteropTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SwaServerInteropTest extends TestCase
2323
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
2424
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
2525
),
26+
'proxy_host' => false,
2627
);
2728

2829
public function testUploadDownloadText()

0 commit comments

Comments
 (0)