]> granicus.if.org Git - apache/commitdiff
Stop compressing if we are doing a HEAD request and the content-length filter
authorStefan Fritsch <sf@apache.org>
Sat, 26 Jun 2010 17:41:01 +0000 (17:41 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 26 Jun 2010 17:41:01 +0000 (17:41 +0000)
can't determine the content-length anyway.

Submitted by: Ruediger Pluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@958253 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_deflate.c

index e40a8b0fcabe8daf55a6db8d943b673137a2017f..c3be180bf7b03723726c609503d38da1651f4be5 100644 (file)
@@ -637,6 +637,19 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
         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)) {