From adc105dac49b1e17641431cf30f8dc7ed834741a Mon Sep 17 00:00:00 2001 From: Thomas Gries Date: Wed, 15 Feb 2012 22:40:38 +0000 Subject: [PATCH] important fix inside HttpFunctions.php. I noticed that when you call HttpRequest::factory with noProxy=true for example inside an intranet, this is ignored in (Curl)HttpRequest because the proxy url is not cleared. This commit makes sure at lowest level - namel in the public function proxySetup() - that a optional(true) value of noProxy is observed and that it (now) also clears the proxy url. (I have been told that I am allowed to commit this patch. Please carefully review, as usual). --- includes/HttpFunctions.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 4f720e95d2..1018658450 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -20,8 +20,9 @@ class Http { * - timeout Timeout length in seconds * - postData An array of key-value pairs or a url-encoded form data * - proxy The proxy to use. - * Will use $wgHTTPProxy (if set) otherwise. - * - noProxy Override $wgHTTPProxy (if set) and don't use any proxy at all. + * Otherwise it will use $wgHTTPProxy (if set) + * Otherwise it will use the environment variable "http_proxy" (if set) + * - noProxy Don't use any proxy at all. Takes precedence over proxy value(s). * - sslVerifyHost (curl only) Verify hostname against certificate * - sslVerifyCert (curl only) Verify SSL certificate * - caInfo (curl only) Provide CA information @@ -286,11 +287,11 @@ class MWHttpRequest { public function proxySetup() { global $wgHTTPProxy; - if ( $this->proxy ) { + if ( $this->proxy && !$this->noProxy ) { return; } - if ( Http::isLocalURL( $this->url ) ) { + if ( Http::isLocalURL( $this->url ) || $this->noProxy ) { $this->proxy = ''; } elseif ( $wgHTTPProxy ) { $this->proxy = $wgHTTPProxy ; @@ -401,9 +402,11 @@ class MWHttpRequest { $this->setReferer( wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) ); } - if ( !$this->noProxy ) { - $this->proxySetup(); - } + /** + * Set up the proxy, but + * clear the proxy when $noProxy is set (takes precedence) + */ + $this->proxySetup(); if ( !$this->callback ) { $this->setCallback( array( $this, 'read' ) ); -- 2.20.1