Index: FeedsHTTPFetcher.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsHTTPFetcher.inc,v
retrieving revision 1.23
diff -u -r1.23 FeedsHTTPFetcher.inc
--- FeedsHTTPFetcher.inc	1 Jul 2010 14:19:18 -0000	1.23
+++ FeedsHTTPFetcher.inc	26 Aug 2010 21:37:18 -0000
@@ -29,10 +29,66 @@
    */
   public function getRaw() {
     feeds_include_library('http_request.inc', 'http_request');
+    //dpm($this->url, 'url');
     $result = http_request_get($this->url);
+    //dpm($result->headers, 'headers');
+    //dpm($result->headers['Content-Type'], 'Content-Type');
+    //Check if we go the proper zip or gzip headers.
+    $compressed = false;
+    if(strpos($result->headers['Content-Type'], 'application/zip')!==false ||
+       strpos($result->headers['Content-Type'], 'application/octet-stream')!==false && strpos($result->headers['Content-Type'], '.zip')!==false){
+        $ext = 'zip';
+        $compressed = true;
+    }
+    if(strpos($result->headers['Content-Type'], 'application/x-gzip')!==false ||
+       strpos($result->headers['Content-Type'], 'application/octet-stream')!==false && strpos($result->headers['Content-Type'], '.gz')!==false){
+        $ext = 'gz';
+        $compressed = true;
+    }
+
+    if($compressed){
+
+        if(!function_exists('gzopen') || !function_exists('zip_open')){
+            drupal_set_message('Zipped file encoding detected, but you dont have PHP with <strong>php_zlib</strong> or <strong>php_zip</strong> support. You file has <em>'.$ext.'</em> extension.','warning');
+        } else {
+
+            $tmp_filename_ = md5(time()).'.'.$ext;
+            $fsd = file_save_data($result->data, file_directory_path().'/'.$tmp_filename_, FILE_EXISTS_REPLACE);
+
+            if($fsd && $ext=='gz'){
+                $zd = gzopen(file_directory_path().'/'.$tmp_filename_, 'r');
+                while (!gzeof($zd)) {
+                    $contents .= gzread($zd, 10000);
+                }
+                gzclose($zd);
+                drupal_set_message('Gzip encoding detected. Decoding the file to xml.');
+            }
+            if($fsd && $ext=='zip'){
+                $zd = zip_open(file_directory_path().'/'.$tmp_filename_);
+                while ($zip_entry = zip_read($zd)) {
+                    if (zip_entry_open($zd, $zip_entry)) {
+                        $contents .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
+                        zip_entry_close($zip_entry);
+                    }
+                }
+                zip_close($zd);
+                drupal_set_message('Zip encoding detected. Decoding the file to xml.');
+
+
+            }
+            //Delete the temporary file.
+            @unlink(file_directory_path().'/'.$tmp_filename_);
+
+            $result->data = trim($contents);
+
+        }
+    }
+    
     if (!in_array($result->code, array(200, 201, 202, 203, 204, 205, 206))) {
       throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->url, '!code' => $result->code)));
     }
+   
+
     return $result->data;
   }
 }

