[SoapClient] Added proxy authentication option in SoapClientBuilder

Fixed #47
This commit is contained in:
Francis Besset
2014-08-18 11:45:53 +02:00
parent 70db0c42fd
commit 1a7f60b679
3 changed files with 28 additions and 1 deletions

View File

@ -177,10 +177,11 @@ class SoapClientBuilder extends AbstractSoapBuilder
* @param int $port Port
* @param string $login Login
* @param string $password Password
* @param int $auth Authentication method
*
* @return \BeSimple\SoapClient\SoapClientBuilder
*/
public function withProxy($host, $port, $login = null, $password = null)
public function withProxy($host, $port, $login = null, $password = null, $auth = null)
{
$this->soapOptions['proxy_host'] = $host;
$this->soapOptions['proxy_port'] = $port;
@ -188,6 +189,14 @@ class SoapClientBuilder extends AbstractSoapBuilder
if ($login) {
$this->soapOptions['proxy_login'] = $login;
$this->soapOptions['proxy_password'] = $password;
if ($auth) {
if (!in_array($auth, array(\CURLAUTH_BASIC, \CURLAUTH_NTLM), true)) {
throw new \InvalidArgumentException('Invalid authentication method: CURLAUTH_BASIC or CURLAUTH_NTLM constants are availables.');
}
$this->soapOptions['proxy_auth'] = $auth;
}
}
return $this;