Added proxy support.

This commit is contained in:
Technosophos
2012-10-26 14:36:03 -05:00
parent 6348d50967
commit 3b09c646ab
2 changed files with 30 additions and 0 deletions

View File

@@ -211,12 +211,25 @@ class Bootstrap {
* the transport layer should wait for an HTTP request. A * the transport layer should wait for an HTTP request. A
* transport MAY ignore this parameter, but the ones included * transport MAY ignore this parameter, but the ones included
* with the library honor it. * with the library honor it.
* - 'transport.ssl.verify': Set this to FALSE to turn off SSL certificate
* verification. This is NOT recommended, but is sometimes necessary for
* certain proxy configurations.
* - 'account' and 'secret' * - 'account' and 'secret'
* - 'username' and 'password' * - 'username' and 'password'
* - 'tenantid' * - 'tenantid'
* - 'endpoint': The full URL to identity services. This is used by stream * - 'endpoint': The full URL to identity services. This is used by stream
* wrappers. * wrappers.
* *
* The CURL wrapper supports proxy settings:
*
* - proxy: the proxy server URL (CURLOPT_PROXY)
* - proxy.userpwd: the proxy username:password (CURLOPT_PROXYUSERPWD)
* - proxy.auth: See CURLOPT_PROXYAUTH
* - proxy.port: The proxy port. (CURLOPT_PROXYPORT)
* - proxy.type: see CURLOPT_PROXYTYPE
* - proxy.tunnel: If this is set to TRUE, attempt to tunnel through the
* proxy. This is recommended when using a proxy. (CURLOPT_HTTPPROXYTUNNEL)
*
* @param array $array * @param array $array
* An associative array of configuration directives. * An associative array of configuration directives.
*/ */

View File

@@ -226,6 +226,22 @@ class CURLTransport implements Transporter {
$opts[CURLOPT_SSL_VERIFYPEER] = $validate; $opts[CURLOPT_SSL_VERIFYPEER] = $validate;
} }
// PROXY settings
$proxyMap = array(
'proxy' => CURLOPT_PROXY,
'proxy.tunnel' => CURLOPT_HTTPPROXYTUNNEL,
'proxy.auth' => CURLOPT_PROXYAUTH,
'proxy.port' => CURLOPT_PROXYPORT,
'proxy.type' => CURLOPT_PROXYTYPE,
'proxy.userpwd' => CURLOPT_USERPWD,
);
foreach ($proxyMap as $conf => $opt) {
if (Bootstrap::hasConfig($conf)) {
$val = Bootstrap::config($conf);
$opts[$opt] = $val;
}
}
// Set all of the curl opts and then execute. // Set all of the curl opts and then execute.
curl_setopt_array($curl, $opts); curl_setopt_array($curl, $opts);
@@ -294,6 +310,7 @@ class CURLTransport implements Transporter {
} }
curl_multi_add_handle($multi, $handle); curl_multi_add_handle($multi, $handle);
// Initialize all of the listeners
$active = NULL; $active = NULL;
do { do {
$ret = curl_multi_exec($multi, $active); $ret = curl_multi_exec($multi, $active);