Index: class-snoopy.php
===================================================================
--- class-snoopy.php	(revision 3879)
+++ class-snoopy.php	(working copy)
@@ -7,6 +7,8 @@
 Copyright (c): 1999-2000 ispi, all rights reserved
 Version: 1.01
 
+Added Gzip Support for Wordpress by Dennis Kruyt (http://kruyt.org).
+
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -100,6 +102,8 @@
 												// library functions built into php,
 												// as these functions are not stable
 												// as of this Snoopy release.
+        // send Accept-encoding: gzip?
+        var $use_gzip           = true;
 
 	/**** Private variables ****/
 
@@ -802,6 +806,21 @@
 		}
 		if(!empty($this->accept))
 			$headers .= "Accept: ".$this->accept."\r\n";
+
+                if($this->use_gzip) {
+                        // make sure PHP was built with --with-zlib
+                        // and we can handle gzipp'ed data
+                        if ( function_exists(gzinflate) ) {
+                           $headers .= "Accept-encoding: gzip\r\n";
+                        }
+                        else {
+                           trigger_error(
+                                "use_gzip is on, but PHP was built without zlib support.".
+                                "  Requesting file(s) without gzip encoding.",
+                                E_USER_NOTICE);
+                        }
+                }
+
 		if(!empty($this->referer))
 			$headers .= "Referer: ".$this->referer."\r\n";
 		if(!empty($this->cookies))
@@ -853,6 +872,9 @@
 		$this->_redirectaddr = false;
 		unset($this->headers);
 
+                // content was returned gzip encoded?
+                $is_gzipped = false;
+
 		while($currentHeader = fgets($fp,$this->_maxlinelen))
 		{
 			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
@@ -892,7 +914,9 @@
                 }
 				$this->response_code = $currentHeader;
 			}
-
+                        if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
+                                $is_gzipped = true;
+                        }
 			$this->headers[] = $currentHeader;
 		}
 
@@ -905,6 +929,13 @@
     		$results .= $_data;
 		} while(true);
 
+               // gunzip
+                if ( $is_gzipped ) {
+                        // per http://www.php.net/manual/en/function.gzencode.php
+                        $results = substr($results, 10);
+                        $results = gzinflate($results);
+                }
+
 		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
 		{
 			$this->status=-100;

