> -----Original Message-----
> From: Geoffrey Young [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 14, 2000 8:34 AM
> To: 'Ken Williams'
> Cc: '[EMAIL PROTECTED]'
> Subject: Apache::Compress patch
> 
> 
> hi ken...
> 
> 
> something has been bugging me in Apache::Compress for a while now - it
> _always_ tries to compress output.
> 
[snip]

whoops on that patch...  it didn't print filtered output that was less than
300 characters *doh*.  This should do the trick (against Compress.pm
1.003)...

--Geoff

--- Compress.pm.old     Thu Dec 14 08:22:15 2000
+++ Compress.pm Mon Dec 18 15:29:26 2000
@@ -35,10 +35,23 @@
   return SERVER_ERROR unless $fh;
   
   if ($can_gzip) {
-    $r->content_encoding('gzip');
-    $r->send_http_header;
     local $/;
-    print Compress::Zlib::memGzip(<$fh>);
+    local $^W;  # length() gives an uninitialized warning. hmmm...
+    my $file = <$fh>;
+
+    my $length = length($file);
+
+    return DECLINED unless $length;
+
+    if ($length < 300) {
+      $r->send_http_header;
+      $r->print($file);
+    }
+    else {
+      $r->content_encoding('gzip');
+      $r->send_http_header;
+      print Compress::Zlib::memGzip($file);
+    }
   } else {
     $r->send_http_header;
     $r->send_fd($fh);


Reply via email to