X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=697391b6d020b27c52ca490d24257b8d25561292;hp=60196aba5b87725d8ea1588aa8ddc37244ae8f11;hb=6ae9367cddf8565c948f4d9458b07bb688f2ddc2;hpb=27dfd0aff41243e35b31ecbfe4ed34cbbe6f57a6 diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 60196aba5b..697391b6d0 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -193,6 +193,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 ""; + } } /** @@ -369,8 +389,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; @@ -380,10 +398,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(); } }