X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=3f42038242ebf7c8eeca86df5d5bf9e4597738b2;hp=1a6e38292bfb2612ff581e4f3a6615a7555b1e46;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hpb=1c80fe572eec7610f35c87e0a43e49d886193d58 diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 1a6e38292b..3f42038242 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -192,6 +192,26 @@ class Http { $uri ); } + + /** + * Gets the relevant proxy from $wgHTTPProxy/http_proxy (when set). + * + * @return mixed The proxy address or an empty string if not set. + */ + public static function getProxy() { + global $wgHTTPProxy; + + if ( $wgHTTPProxy ) { + return $wgHTTPProxy; + } + + $envHttpProxy = getenv( "http_proxy" ); + if ( $envHttpProxy ) { + return $envHttpProxy; + } + + return ""; + } } /** @@ -368,8 +388,6 @@ class MWHttpRequest { * @return void */ public function proxySetup() { - global $wgHTTPProxy; - // If there is an explicit proxy set and proxies are not disabled, then use it if ( $this->proxy && !$this->noProxy ) { return; @@ -379,10 +397,8 @@ class MWHttpRequest { // local URL and proxies are not disabled if ( Http::isLocalURL( $this->url ) || $this->noProxy ) { $this->proxy = ''; - } elseif ( $wgHTTPProxy ) { - $this->proxy = $wgHTTPProxy; - } elseif ( getenv( "http_proxy" ) ) { - $this->proxy = getenv( "http_proxy" ); + } else { + $this->proxy = Http::getProxy(); } }