r111588: refactored proxy/noProxy code slightly for simplicity
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 29 Feb 2012 00:36:40 +0000 (00:36 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 29 Feb 2012 00:36:40 +0000 (00:36 +0000)
includes/HttpFunctions.php

index 23ea8df..8dd6525 100644 (file)
@@ -219,6 +219,10 @@ class MWHttpRequest {
                                $this->$o = $options[$o];
                        }
                }
+
+               if ( $this->noProxy ) {
+                       $this->proxy = ''; // noProxy takes precedence
+               }
        }
 
        /**
@@ -279,15 +283,14 @@ class MWHttpRequest {
        }
 
        /**
-        * Take care of setting up the proxy
-        * (override in subclass)
+        * Take care of setting up the proxy (do nothing if "noProxy" is set)
         *
-        * @return String
+        * @return void
         */
        public function proxySetup() {
                global $wgHTTPProxy;
 
-               if ( $this->proxy && !$this->noProxy ) {
+               if ( $this->proxy || !$this->noProxy ) {
                        return;
                }
 
@@ -402,11 +405,7 @@ class MWHttpRequest {
                        $this->setReferer( wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) );
                }
 
-               /**
-                * Set up the proxy, but
-                * clear the proxy when $noProxy is set (takes precedence)
-                */
-               $this->proxySetup();
+               $this->proxySetup(); // set up any proxy as needed
 
                if ( !$this->callback ) {
                        $this->setCallback( array( $this, 'read' ) );
@@ -805,7 +804,7 @@ class PhpHttpRequest extends MWHttpRequest {
                }
 
                $options = array();
-               if ( $this->proxy && !$this->noProxy ) {
+               if ( $this->proxy ) {
                        $options['proxy'] = $this->urlToTCP( $this->proxy );
                        $options['request_fulluri'] = true;
                }