X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=includes%2Flibs%2FMultiHttpClient.php;h=fb2daa691459e15f68961628dd76afc7f53ff44d;hb=b5cf0db5627d6c0bd3483db5ed57e50dfee36227;hp=eeda8d4cc0253105928e4632f5b625a49aaf8895;hpb=fb009e4f3441a4b49fea60c0a3e431ccacc14995;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index eeda8d4cc0..fb2daa6914 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -34,6 +34,7 @@ * array bodies are encoded as multipart/form-data and strings * use application/x-www-form-urlencoded (headers sent automatically) * - stream : resource to stream the HTTP response body to + * - proxy : HTTP proxy to use * Request maps can use integer index 0 instead of 'method' and 1 instead of 'url'. * * @author Aaron Schulz @@ -52,11 +53,14 @@ class MultiHttpClient { protected $usePipelining = false; /** @var integer */ protected $maxConnsPerHost = 50; + /** @var string|null proxy */ + protected $proxy; /** * @param array $options * - connTimeout : default connection timeout * - reqTimeout : default request timeout + * - proxy : HTTP proxy to use * - usePipelining : whether to use HTTP pipelining if possible (for all hosts) * - maxConnsPerHost : maximum number of concurrent connections (per host) * @throws Exception @@ -68,7 +72,7 @@ class MultiHttpClient { throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath ); } } - static $opts = array( 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost' ); + static $opts = array( 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy' ); foreach ( $opts as $key ) { if ( isset( $options[$key] ) ) { $this->$key = $options[$key]; @@ -253,6 +257,7 @@ class MultiHttpClient { curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, isset( $opts['connTimeout'] ) ? $opts['connTimeout'] : $this->connTimeout ); + curl_setopt( $ch, CURLOPT_PROXY, isset( $req['proxy'] ) ? $req['proxy'] : $this->proxy ); curl_setopt( $ch, CURLOPT_TIMEOUT, isset( $opts['reqTimeout'] ) ? $opts['reqTimeout'] : $this->reqTimeout ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );