From 1caa46ec99c0c80a81f635ecf0a39aebdf8206a6 Mon Sep 17 00:00:00 2001 From: Hovhannes Kuloghlyan Date: Wed, 23 Apr 2014 10:34:41 +0400 Subject: [PATCH] fix gzip header parsing in getContents --- UAS/Parser.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/UAS/Parser.php b/UAS/Parser.php index 393724a..23c26f0 100755 --- a/UAS/Parser.php +++ b/UAS/Parser.php @@ -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');