$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 "";
+ }
}
/**
* @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;
// 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();
}
}
);
}
+ /**
+ * @covers Http::getProxy
+ */
+ public function testGetProxy() {
+ $this->setMwGlobals( 'wgHTTPProxy', 'proxy.domain.tld' );
+ $this->assertEquals(
+ 'proxy.domain.tld',
+ Http::getProxy()
+ );
+ }
+
/**
* Feeds URI to test a long regular expression in Http::isValidURI
*/