This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 080fa6cf7e Further improve with feedback from 69575 080fa6cf7e is described below commit 080fa6cf7e4b4e74fab110eb10a95539ce027179 Author: remm <r...@apache.org> AuthorDate: Thu Feb 20 21:41:26 2025 +0100 Further improve with feedback from 69575 Add to existing content-encoding header values when compressing. Skip compression with content-encoding with "identity". Add more content-encoding values based on HTTP Content Coding Registry (skip deprecated values). --- java/org/apache/coyote/CompressionConfig.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/java/org/apache/coyote/CompressionConfig.java b/java/org/apache/coyote/CompressionConfig.java index 3545db1a52..b32c18ef1c 100644 --- a/java/org/apache/coyote/CompressionConfig.java +++ b/java/org/apache/coyote/CompressionConfig.java @@ -194,6 +194,7 @@ public class CompressionConfig { } boolean useTE = false; + boolean useCE = true; MimeHeaders responseHeaders = response.getMimeHeaders(); @@ -211,8 +212,13 @@ public class CompressionConfig { log.warn(sm.getString("compressionConfig.ContentEncodingParseFail"), e); return false; } - if (tokens.contains("gzip") || tokens.contains("compress") || tokens.contains("deflate") - || tokens.contains("br") || tokens.contains("zstd")) { + if (tokens.contains("identity")) { + // If identity, do not do content modifications + useCE = false; + } else if (tokens.contains("br") || tokens.contains("compress") || tokens.contains("dcb") + || tokens.contains("dcz") || tokens.contains("deflate") || tokens.contains("gzip") + || tokens.contains("pack200-gzip") || tokens.contains("zstd")) { + // Content should not be compressed twice return false; } } @@ -262,7 +268,7 @@ public class CompressionConfig { return false; } - if (!useTE) { + if (useCE && !useTE) { // If processing reaches this far, the response might be compressed. // Therefore, set the Vary header to keep proxies happy ResponseUtil.addVaryFieldName(responseHeaders, "accept-encoding"); @@ -318,7 +324,7 @@ public class CompressionConfig { responseHeaders.addValue("Transfer-Encoding").setString("gzip"); } else { // Configure the content encoding for compressed content - responseHeaders.setValue("Content-Encoding").setString("gzip"); + responseHeaders.addValue("Content-Encoding").setString("gzip"); } return true; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org