X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=3f42038242ebf7c8eeca86df5d5bf9e4597738b2;hp=f980a93d56e2f83fcb40e1894435f4f7d6124201;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hpb=989feebb73352d690adbdc7a94fce8245cb78882 diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index f980a93d56..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(); } } @@ -991,7 +1007,7 @@ class PhpHttpRequest extends MWHttpRequest { ]; if ( $this->proxy ) { - $options['http']['proxy'] = $this->urlToTCP( $this->proxy ); + $options['http']['proxy'] = $this->urlToTcp( $this->proxy ); $options['http']['request_fulluri'] = true; }