From 0ae75f345309a0d42cd906b5a69fefc47fbf5d7f Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Fri, 3 Sep 2021 16:50:33 +0000 Subject: [PATCH] Merge r1892728 from trunk: * 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index b1cb15453fd..2431fd7e8c9 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -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) -- 2.47.2