Merge "Added a simple JobSpecification class for pushing jobs"
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index 6fcb7ce..2536de1 100644 (file)
@@ -30,7 +30,7 @@
  * @ingroup HTTP
  */
 class Http {
-       static $httpEngine = false;
+       static public $httpEngine = false;
 
        /**
         * Perform an HTTP request
@@ -130,7 +130,8 @@ class Http {
                        $domainParts = array_reverse( $domainParts );
 
                        $domain = '';
-                       for ( $i = 0; $i < count( $domainParts ); $i++ ) {
+                       $countParts = count( $domainParts );
+                       for ( $i = 0; $i < $countParts; $i++ ) {
                                $domainPart = $domainParts[$i];
                                if ( $i == 0 ) {
                                        $domain = $domainPart;
@@ -294,8 +295,11 @@ class MWHttpRequest {
                                return new CurlHttpRequest( $url, $options );
                        case 'php':
                                if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
-                                       throw new MWException( __METHOD__ . ': allow_url_fopen needs to be enabled for pure PHP' .
-                                               ' http requests to work. If possible, curl should be used instead. See http://php.net/curl.' );
+                                       throw new MWException( __METHOD__ . ': allow_url_fopen ' .
+                                               'needs to be enabled for pure PHP http requests to ' .
+                                               'work. If possible, curl should be used instead. See ' .
+                                               'http://php.net/curl.'
+                                       );
                                }
                                return new PhpHttpRequest( $url, $options );
                        default:
@@ -346,13 +350,6 @@ class MWHttpRequest {
                }
        }
 
-       /**
-        * Set the referrer header
-        */
-       public function setReferer( $url ) {
-               $this->setHeader( 'Referer', $url );
-       }
-
        /**
         * Set the user agent
         * @param $UA string
@@ -437,8 +434,6 @@ class MWHttpRequest {
         * @return Status
         */
        public function execute() {
-               global $wgTitle;
-
                wfProfileIn( __METHOD__ );
 
                $this->content = "";
@@ -447,10 +442,6 @@ class MWHttpRequest {
                        $this->headersOnly = true;
                }
 
-               if ( is_object( $wgTitle ) && !isset( $this->reqHeaders['Referer'] ) ) {
-                       $this->setReferer( wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) );
-               }
-
                $this->proxySetup(); // set up any proxy as needed
 
                if ( !$this->callback ) {
@@ -642,12 +633,16 @@ class MWHttpRequest {
        /**
         * Returns the final URL after all redirections.
         *
-        * Relative values of the "Location" header are incorrect as stated in RFC, however they do happen and modern browsers support them.
-        * This function loops backwards through all locations in order to build the proper absolute URI - Marooned at wikia-inc.com
+        * Relative values of the "Location" header are incorrect as
+        * stated in RFC, however they do happen and modern browsers
+        * support them.  This function loops backwards through all
+        * locations in order to build the proper absolute URI - Marooned
+        * at wikia-inc.com
         *
-        * Note that the multiple Location: headers are an artifact of CURL -- they
-        * shouldn't actually get returned this way. Rewrite this when bug 29232 is
-        * taken care of (high-level redirect handling rewrite).
+        * Note that the multiple Location: headers are an artifact of
+        * CURL -- they shouldn't actually get returned this way. Rewrite
+        * this when bug 29232 is taken care of (high-level redirect
+        * handling rewrite).
         *
         * @return string
         */
@@ -678,7 +673,8 @@ class MWHttpRequest {
                                } else {
                                        $url = parse_url( $this->url );
                                        if ( isset( $url['host'] ) ) {
-                                               return $url['scheme'] . '://' . $url['host'] . $locations[$countLocations - 1];
+                                               return $url['scheme'] . '://' . $url['host'] .
+                                                       $locations[$countLocations - 1];
                                        }
                                }
                        } else {
@@ -742,10 +738,6 @@ class CurlHttpRequest extends MWHttpRequest {
                $this->curlOptions[CURLOPT_MAXREDIRS] = $this->maxRedirects;
                $this->curlOptions[CURLOPT_ENCODING] = ""; # Enable compression
 
-               /* not sure these two are actually necessary */
-               if ( isset( $this->reqHeaders['Referer'] ) ) {
-                       $this->curlOptions[CURLOPT_REFERER] = $this->reqHeaders['Referer'];
-               }
                $this->curlOptions[CURLOPT_USERAGENT] = $this->reqHeaders['User-Agent'];
 
                $this->curlOptions[CURLOPT_SSL_VERIFYHOST] = $this->sslVerifyHost ? 2 : 0;