Running ProxyPass with mod_deflate results in
an extraneous 20 bytes being tacked onto 304
responses from the backend.

The problem is that mod_deflate doesn't handle
the zero byte body, adds the gzip header and
tries to compress 0 bytes.

This patch detects the fact that there was no
data to compress and removes the gzip header
from the bucket brigade.

Any comments before I commit to head?

Allan
------------------------------
Index: mod_deflate.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/filters/mod_deflate.c,v
retrieving revision 1.49
diff -u -d -b -r1.49 mod_deflate.c
--- mod_deflate.c       1 Jun 2004 13:06:10 -0000       1.49
+++ mod_deflate.c       9 Jun 2004 16:38:30 -0000
@@ -433,6 +433,8 @@
             char *buf;
             unsigned int deflate_len;

+            if (ctx->stream.total_in != 0) {
+
             ctx->stream.avail_in = 0; /* should be zero already anyway */
             for (;;) {
                 deflate_len = c->bufferSize - ctx->stream.avail_out;
@@ -510,6 +512,14 @@
              * Time to pass it along down the chain.
              */
             return ap_pass_brigade(f->next, ctx->bb);
+            }
+            else {
+                /* this was a zero length response, remove gzip header bucket then 
pass down the EOS */
+                APR_BUCKET_REMOVE(APR_BRIGADE_FIRST(ctx->bb));
+                APR_BUCKET_REMOVE(e);
+                APR_BRIGADE_INSERT_TAIL(ctx->bb, e);
+                return ap_pass_brigade(f->next, ctx->bb);
+            }
         }

         if (APR_BUCKET_IS_FLUSH(e)) {





Reply via email to