From: Platonides Date: Tue, 8 Jun 2010 20:01:22 +0000 (+0000) Subject: Enable http compression. X-Git-Tag: 1.31.0-rc.0~36578 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=52d874ca623859e91f74ee6744ddc65666207979;p=lhc%2Fweb%2Fwiklou.git Enable http compression. Skip "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set" error. --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index b9b1cf99a0..bd59ffe768 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -1,4 +1,4 @@ -curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; $this->curlOptions[CURLOPT_WRITEFUNCTION] = $this->callback; $this->curlOptions[CURLOPT_HEADERFUNCTION] = array($this, "readHeader"); - $this->curlOptions[CURLOPT_FOLLOWLOCATION] = $this->followRedirects; $this->curlOptions[CURLOPT_MAXREDIRS] = $this->maxRedirects; + $this->curlOptions[CURLOPT_ENCODING] = ""; # Enable compression /* not sure these two are actually necessary */ if(isset($this->reqHeaders['Referer'])) { @@ -767,7 +767,13 @@ class CurlHttpRequest extends HttpRequest { $this->curlOptions[CURLOPT_HTTPHEADER] = $this->getHeaderList(); $curlHandle = curl_init( $this->url ); - curl_setopt_array( $curlHandle, $this->curlOptions ); + if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) { + throw new MWException("Error setting curl options."); + } + if ( ! @curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION, $this->followRedirects ) ) { + wfDebug("Couldn't set CURLOPT_FOLLOWLOCATION. Probably safe_mode or open_basedir is set."); + /* Continue the processing. If it were in curl_setopt_array, processing would have halted on its entry */ + } if ( false === curl_exec( $curlHandle ) ) { $code = curl_error( $curlHandle );