Support HTTP timeout detection in curl backend
authorChad Horohoe <chadh@wikimedia.org>
Tue, 16 Apr 2013 23:07:12 +0000 (19:07 -0400)
committerDemon <chadh@wikimedia.org>
Tue, 16 Apr 2013 23:11:54 +0000 (23:11 +0000)
We already do this for the pure-PHP backend, and it's easy to
catch this single error and pass a more specific message

Change-Id: I8a81dd90b691c35c51a19f8790f06578dd067613

includes/HttpFunctions.php

index acf9baa..489a83a 100644 (file)
@@ -774,7 +774,10 @@ class CurlHttpRequest extends MWHttpRequest {
                        wfRestoreWarnings();
                }
 
-               if ( false === curl_exec( $curlHandle ) ) {
+               $curlRes = curl_exec( $curlHandle );
+               if ( curl_errno( $curlHandle ) == CURLE_OPERATION_TIMEOUTED ) {
+                       $this->status->fatal( 'http-timed-out', $this->url );
+               } elseif ( $curlRes === false ) {
                        $this->status->fatal( 'http-curl-error', curl_error( $curlHandle ) );
                } else {
                        $this->headerList = explode( "\r\n", $this->headerText );