diff --git a/README.md b/README.md index 04b8cb5..578cf09 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,14 @@ $soapClient->useProxy('proxy.local', 8080, CURLPROXY_SOCKS5); The default hostname, port and type for this methods are `localhost`, `8888` and `CURLPROXY_HTTP`, which is the default binding for Fiddler Web Debugging Proxy ([http://fiddler2.com/](http://fiddler2.com/)). +### Proxy Auth ### + +If your proxy need auth, you can use this method to set proxy username and password: +```php +setProxyAuth('proxy_user', 'proxy_password'); +``` + ### Authentication ### In order to use HTTP Authentication, use SoapClient original `login` and `password` options. The cURL client will get it from there. diff --git a/src/Camcima/Soap/Client.php b/src/Camcima/Soap/Client.php index 5d2e1c4..be926ec 100644 --- a/src/Camcima/Soap/Client.php +++ b/src/Camcima/Soap/Client.php @@ -72,6 +72,20 @@ class Client extends \SoapClient */ protected $proxyPort; + /** + * Proxy User + * + * @var string + */ + protected $proxyUser; + + /** + * Proxy Password + * + * @var string + */ + protected $proxyPass; + /** * Lowercase first character of the root element name * @@ -360,6 +374,21 @@ public function useProxy($host = self::DEFAULT_PROXY_HOST, $port = self::DEFAULT return $this; } + /** + * Set proxy auth data + * + * @param $user + * @param $passwd + * @return $this + */ + public function setProxyAuth($user, $passwd) + { + $this->proxyUser = $user; + $this->proxyPass = $passwd; + + return $this; + } + /** * Merge Curl Options * @@ -389,6 +418,7 @@ public function getCurlOptions() $mergedArray[CURLOPT_PROXYTYPE] = $this->proxyType; $mergedArray[CURLOPT_PROXY] = $this->proxyHost; $mergedArray[CURLOPT_PROXYPORT] = $proxyPort; + $mergedArray[CURLOPT_PROXYUSERPWD] = $this->proxyUser . ':' . $this->proxyPass; } return $mergedArray;