X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhttp%2FCurlHttpRequest.php;h=5130e36fb5c2f65ec049b0575b04920fef0e51cc;hb=8d9d8c8bb319482919d3d62732b9a0f689ede052;hp=f457b2192ce2fb2e7c27697ce42999dfb589fe6a;hpb=2f1e5a8d22d7c005e72f8bdb732e6d7076ac3344;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/http/CurlHttpRequest.php b/includes/http/CurlHttpRequest.php index f457b2192c..5130e36fb5 100644 --- a/includes/http/CurlHttpRequest.php +++ b/includes/http/CurlHttpRequest.php @@ -27,6 +27,18 @@ class CurlHttpRequest extends MWHttpRequest { protected $curlOptions = []; protected $headerText = ""; + /** + * @throws RuntimeException + */ + public function __construct() { + if ( !function_exists( 'curl_init' ) ) { + throw new RuntimeException( + __METHOD__ . ': curl (https://www.php.net/curl) is not installed' ); + } + + parent::__construct( ...func_get_args() ); + } + /** * @param resource $fh * @param string $content @@ -52,12 +64,7 @@ class CurlHttpRequest extends MWHttpRequest { $this->curlOptions[CURLOPT_PROXY] = $this->proxy; $this->curlOptions[CURLOPT_TIMEOUT] = $this->timeout; - - // Only supported in curl >= 7.16.2 - if ( defined( 'CURLOPT_CONNECTTIMEOUT_MS' ) ) { - $this->curlOptions[CURLOPT_CONNECTTIMEOUT_MS] = $this->connectTimeout * 1000; - } - + $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] = [ $this, "readHeader" ]; @@ -98,6 +105,7 @@ class CurlHttpRequest extends MWHttpRequest { $curlHandle = curl_init( $this->url ); if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) { + $this->status->fatal( 'http-internal-error' ); throw new InvalidArgumentException( "Error setting curl options." ); }