Skip to content

Commit

Permalink
Add option not to use zip compression
Browse files Browse the repository at this point in the history
  • Loading branch information
yarroslav committed Apr 22, 2014
1 parent 5d765f4 commit 425ff83
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions UAS/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -460,7 +465,7 @@ protected function getContents($url, $timeout = 300)
array(
'http' => array(
'timeout' => $timeout,
'header' => "Accept-Encoding: gzip\r\n"
'header' => ($this->useZipDownloads ? "Accept-Encoding: gzip\r\n" : "")
)
)
)
Expand Down Expand Up @@ -506,9 +511,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(
Expand Down Expand Up @@ -552,6 +563,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
Expand Down

0 comments on commit 425ff83

Please sign in to comment.