diff --git a/UAS/Parser.php b/UAS/Parser.php index 23c26f0..77112cc 100755 --- a/UAS/Parser.php +++ b/UAS/Parser.php @@ -47,7 +47,12 @@ class Parser * @type bool */ protected $doDownloads = true; - + /** + * Should this instance use zip compression while downloads + * Useful if use mbstring.func_overload + * @type bool + */ + protected $useZipDownloads = true; /** * URL to fetch the full data file from. * @type string @@ -452,18 +457,19 @@ protected function getContents($url, $timeout = 300) $starttime = microtime(true); // use fopen if (ini_get('allow_url_fopen')) { + $stream_options = array( + 'http' => array( + 'timeout' => $timeout + ) + ); + if ($this->useZipDownloads) { + $stream_options['http']['header'] = "Accept-Encoding: gzip\r\n"; + } $fp = @fopen( $url, 'rb', false, - stream_context_create( - array( - 'http' => array( - 'timeout' => $timeout, - 'header' => "Accept-Encoding: gzip\r\n" - ) - ) - ) + stream_context_create($stream_options) ); if (is_resource($fp)) { $data = stream_get_contents($fp); @@ -513,9 +519,15 @@ protected function getContents($url, $timeout = 300) CURLOPT_TIMEOUT => $timeout, CURLOPT_CONNECTTIMEOUT => $timeout, CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => 'gzip' ) ); + if ($this->useZipDownloads) { + curl_setopt( + $ch, + CURLOPT_ENCODING, + 'gzip' + ); + } $data = curl_exec($ch); if ($data !== false and curl_errno($ch) == 0) { $this->debug( @@ -559,6 +571,14 @@ public function setCacheDir($cache_dir) return true; } + /** + * Set use zip compression while downloading updates. + * @param bool $use + */ + public function setUseZipDownloads($use) { + $this->useZipDownloads = (bool)$use; + } + /** * Get the cache directory * @return string