Skip to content

Commit

Permalink
Merge pull request #14 from h0vhannes/master
Browse files Browse the repository at this point in the history
fix gzip header parsing in getContents
  • Loading branch information
Synchro committed Apr 23, 2014
2 parents 5d765f4 + 1caa46e commit 7132cb9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions UAS/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,15 @@ protected function getContents($url, $timeout = 300)
if (is_resource($fp)) {
$data = stream_get_contents($fp);
$res = stream_get_meta_data($fp);
if (array_key_exists('wrapper_data', $res)) {
foreach ($res['wrapper_data'] as $d) {
$headers = array();
if (array_key_exists('wrapper_data', $res) && array_key_exists('headers', $res['wrapper_data']) ) {
$headers = $res['wrapper_data']['headers'];
}
elseif (array_key_exists('wrapper_data', $res) ) {
$headers = $res['wrapper_data'];
}
if( !empty($headers) ) {
foreach ($headers as $d) {
if ($d == 'Content-Encoding: gzip') { //Data was compressed
$data = gzinflate(substr($data, 10, -8)); //Uncompress data
$this->debug('Successfully uncompressed data');
Expand Down

0 comments on commit 7132cb9

Please sign in to comment.