You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2010/06/26 19:41:01 UTC

svn commit: r958253 - /httpd/httpd/trunk/modules/filters/mod_deflate.c

Author: sf
Date: Sat Jun 26 17:41:01 2010
New Revision: 958253

URL: http://svn.apache.org/viewvc?rev=958253&view=rev
Log:
Stop compressing if we are doing a HEAD request and the content-length filter
can't determine the content-length anyway.

Submitted by: Ruediger Pluem

Modified:
    httpd/httpd/trunk/modules/filters/mod_deflate.c

Modified: httpd/httpd/trunk/modules/filters/mod_deflate.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_deflate.c?rev=958253&r1=958252&r2=958253&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_deflate.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_deflate.c Sat Jun 26 17:41:01 2010
@@ -637,6 +637,19 @@ static apr_status_t deflate_out_filter(a
         apr_bucket *b;
         apr_size_t len;
 
+        /*
+         * Optimization: If we are a HEAD request and bytes_sent is not zero
+         * it means that we have passed the content-length filter once and
+         * have more data to sent. This means that the content-length filter
+         * could not determine our content-length for the response to the
+         * HEAD request anyway (the associated GET request would deliver the
+         * body in chunked encoding) and we can stop compressing.
+         */
+        if (r->header_only && r->bytes_sent) {
+            ap_remove_output_filter(f);
+            return ap_pass_brigade(f->next, bb);
+        }
+
         e = APR_BRIGADE_FIRST(bb);
 
         if (APR_BUCKET_IS_EOS(e)) {