Restore compatibility with curl < 7.16.2
authorKevin Israel <pleasestand@live.com>
Mon, 9 Dec 2013 16:29:28 +0000 (11:29 -0500)
committerKevin Israel <pleasestand@live.com>
Mon, 9 Dec 2013 16:34:22 +0000 (11:34 -0500)
Follows-up 58f71c7e9eca, which assumed that the CURLOPT_CONNECTTIMEOUT_MS
constant was defined.

Bug: 58178
Change-Id: Id31a3ec56e4c7cac7d3edb2653c87be467d1a471

includes/HttpFunctions.php

index da08aa2..6fcb7ce 100644 (file)
@@ -730,7 +730,12 @@ class CurlHttpRequest extends MWHttpRequest {
 
                $this->curlOptions[CURLOPT_PROXY] = $this->proxy;
                $this->curlOptions[CURLOPT_TIMEOUT] = $this->timeout;
-               $this->curlOptions[CURLOPT_CONNECTTIMEOUT_MS] = $this->connectTimeout * 1000;
+
+               // Only supported in curl >= 7.16.2
+               if ( defined( 'CURLOPT_CONNECTTIMEOUT_MS' ) ) {
+                       $this->curlOptions[CURLOPT_CONNECTTIMEOUT_MS] = $this->connectTimeout * 1000;
+               }
+
                $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
                $this->curlOptions[CURLOPT_WRITEFUNCTION] = $this->callback;
                $this->curlOptions[CURLOPT_HEADERFUNCTION] = array( $this, "readHeader" );