This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 b6ddc04c8c Review "Do not compress partial content with a content
coding (#1115)"
b6ddc04c8c is described below
commit b6ddc04c8c54c59c85b4d341a1e43cb92e6766fd
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 5 19:25:02 2026 +0000
Review "Do not compress partial content with a content coding (#1115)"
Fix Vary header
---
java/org/apache/coyote/CompressionConfig.java | 11 +++++------
.../apache/coyote/TestCompressionConfigPartialContent.java | 3 ++-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/coyote/CompressionConfig.java
b/java/org/apache/coyote/CompressionConfig.java
index c402869b77..a5660fe7da 100644
--- a/java/org/apache/coyote/CompressionConfig.java
+++ b/java/org/apache/coyote/CompressionConfig.java
@@ -346,17 +346,16 @@ public class CompressionConfig {
}
if (useContentEncoding && !useTransferEncoding) {
- // If processing reaches this far, the response might be
compressed.
- // Therefore, set the Vary header to keep proxies happy
- ResponseUtil.addVaryFieldName(responseHeaders, "accept-encoding");
-
// The ranges of a partial response refer to the bytes of the
representation so it must not be content
// encoded. The Content-Range header is not present at the top
level of a multipart/byteranges response.
- if (response.getStatus() == 206 ||
- responseHeaders.getHeader("Content-Range") != null) {
+ if (response.getStatus() == 206 ||
responseHeaders.getHeader("Content-Range") != null) {
return false;
}
+ // If processing reaches this far, the response might be
compressed.
+ // Therefore, set the Vary header to keep proxies happy
+ ResponseUtil.addVaryFieldName(responseHeaders, "accept-encoding");
+
/*
* Check if user-agent supports gzip encoding. Only interested in
whether gzip encoding is supported. Other
* encodings can be ignored.
diff --git a/test/org/apache/coyote/TestCompressionConfigPartialContent.java
b/test/org/apache/coyote/TestCompressionConfigPartialContent.java
index d645a9d3b8..9e6dfea95d 100644
--- a/test/org/apache/coyote/TestCompressionConfigPartialContent.java
+++ b/test/org/apache/coyote/TestCompressionConfigPartialContent.java
@@ -66,8 +66,9 @@ public class TestCompressionConfigPartialContent {
response.setStatus(206);
response.getMimeHeaders().addValue("Content-Range").setString("bytes
0-99/1000");
+ // The response is never compressed so it does not vary with
Accept-Encoding
Assert.assertFalse(useCompression("accept-encoding", response));
- Assert.assertEquals(1, countVaryAcceptEncoding(response));
+ Assert.assertEquals(0, countVaryAcceptEncoding(response));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]