From 52d874ca623859e91f74ee6744ddc65666207979 Mon Sep 17 00:00:00 2001 From: Platonides Date: Tue, 8 Jun 2010 20:01:22 +0000 Subject: [PATCH] Enable http compression. Skip "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set" error. --- includes/HttpFunctions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 ); -- 2.20.1