]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1892728 from trunk:
authorYann Ylavic <ylavic@apache.org>
Fri, 3 Sep 2021 16:50:33 +0000 (16:50 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 3 Sep 2021 16:50:33 +0000 (16:50 +0000)
 * mod_deflate: refrain from reading buckets of known length, just
   to get their length. This may transform buckets unwanted (e.g. file
   to mmap) and prevent optimization down the filter chain.

Submitted by: icing
Reviewed by: icing, ylavic, jorton

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1892873 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_deflate.c

index b1cb15453fde2631c048fd47000fbc8dc7704d75..2431fd7e8c9d3764c128948e613678b36add2ca4 100644 (file)
@@ -583,9 +583,14 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
                     continue;
                 }
 
-                rc = apr_bucket_read(e, &data, &blen, APR_BLOCK_READ);
-                if (rc != APR_SUCCESS)
-                    return rc;
+                if (e->length == (apr_size_t)-1) {
+                    rc = apr_bucket_read(e, &data, &blen, APR_BLOCK_READ);
+                    if (rc != APR_SUCCESS)
+                        return rc;
+                }
+                else {
+                    blen = e->length;
+                }
                 len += blen;
                 /* 50 is for Content-Encoding and Vary headers and ETag suffix */
                 if (len > sizeof(gzip_header) + VALIDATION_SIZE + 50)