This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new e62b04efe1 Further improve with feedback from 69575
e62b04efe1 is described below
commit e62b04efe16f32cd10499550bcbd8b7c6a453818
Author: remm <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]