Adding output parameter to PageHistoryBeforeList hook
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index 9e9f0da..27b1749 100644 (file)
@@ -35,9 +35,9 @@ class Http {
        /**
         * Perform an HTTP request
         *
-        * @param $method String: HTTP method. Usually GET/POST
-        * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL
-        * @param $options Array: options to pass to MWHttpRequest object.
+        * @param string $method HTTP method. Usually GET/POST
+        * @param string $url full URL to act on. If protocol-relative, will be expanded to an http:// URL
+        * @param array $options options to pass to MWHttpRequest object.
         *      Possible keys for the array:
         *    - timeout             Timeout length in seconds
         *    - postData            An array of key-value pairs or a url-encoded form data
@@ -45,9 +45,7 @@ class Http {
         *                          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) Set to 2 to verify hostname against certificate
-        *                                  Setting to 1 (or true) will NOT verify the host name. It will
-        *                                  only check its existence. Setting to 0 (or false) disables entirely.
+        *    - sslVerifyHost       (curl only) Verify hostname against certificate
         *    - sslVerifyCert       (curl only) Verify SSL certificate
         *    - caInfo              (curl only) Provide CA information
         *    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
@@ -105,7 +103,7 @@ class Http {
        /**
         * Check if the URL can be served by localhost
         *
-        * @param $url String: full url to check
+        * @param string $url full url to check
         * @return Boolean
         */
        public static function isLocalURL( $url ) {
@@ -187,15 +185,7 @@ class MWHttpRequest {
        protected $postData = null;
        protected $proxy = null;
        protected $noProxy = false;
-       /**
-        * Parameter passed to Curl that specifies whether
-        * to validate SSL certificates.
-        *
-        * Setting to 0 disables entirely. Setting to 1 checks
-        * the existence of a CN, but doesn't verify it. Setting
-        * to 2 (the default) actually verifies the host.
-        */
-       protected $sslVerifyHost = 2;
+       protected $sslVerifyHost = true;
        protected $sslVerifyCert = true;
        protected $caInfo = null;
        protected $method = "GET";
@@ -219,8 +209,8 @@ class MWHttpRequest {
        public $status;
 
        /**
-        * @param $url String: url to use. If protocol-relative, will be expanded to an http:// URL
-        * @param $options Array: (optional) extra params to pass (see Http::request())
+        * @param string $url url to use. If protocol-relative, will be expanded to an http:// URL
+        * @param array $options (optional) extra params to pass (see Http::request())
         */
        protected function __construct( $url, $options = array() ) {
                global $wgHTTPTimeout;
@@ -273,8 +263,8 @@ class MWHttpRequest {
 
        /**
         * Generate a new request object
-        * @param $url String: url to use
-        * @param $options Array: (optional) extra params to pass (see Http::request())
+        * @param string $url url to use
+        * @param array $options (optional) extra params to pass (see Http::request())
         * @throws MWException
         * @return CurlHttpRequest|PhpHttpRequest
         * @see MWHttpRequest::__construct
@@ -338,7 +328,7 @@ class MWHttpRequest {
                if ( Http::isLocalURL( $this->url ) || $this->noProxy ) {
                        $this->proxy = '';
                } elseif ( $wgHTTPProxy ) {
-                       $this->proxy = $wgHTTPProxy ;
+                       $this->proxy = $wgHTTPProxy;
                } elseif ( getenv( "http_proxy" ) ) {
                        $this->proxy = getenv( "http_proxy" );
                }
@@ -516,7 +506,6 @@ class MWHttpRequest {
                return (int)$this->respStatus;
        }
 
-
        /**
         * Returns true if the last status code was a redirect.
         *
@@ -653,7 +642,7 @@ class MWHttpRequest {
 
                                if ( isset( $url['host'] ) ) {
                                        $domain = $url[ 'scheme' ] . '://' . $url[ 'host' ];
-                                       break;  //found correct URI (with host)
+                                       break; //found correct URI (with host)
                                } else {
                                        $foundRelativeURI = true;
                                }
@@ -731,13 +720,8 @@ class CurlHttpRequest extends MWHttpRequest {
                }
                $this->curlOptions[CURLOPT_USERAGENT] = $this->reqHeaders['User-Agent'];
 
-               if ( isset( $this->sslVerifyHost ) ) {
-                       $this->curlOptions[CURLOPT_SSL_VERIFYHOST] = $this->sslVerifyHost;
-               }
-
-               if ( isset( $this->sslVerifyCert ) ) {
-                       $this->curlOptions[CURLOPT_SSL_VERIFYPEER] = $this->sslVerifyCert;
-               }
+               $this->curlOptions[CURLOPT_SSL_VERIFYHOST] = $this->sslVerifyHost ? 2 : 0;
+               $this->curlOptions[CURLOPT_SSL_VERIFYPEER] = $this->sslVerifyCert;
 
                if ( $this->caInfo ) {
                        $this->curlOptions[CURLOPT_CAINFO] = $this->caInfo;