This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 0dca2f1722 Revert "Keep the Last-Modified header for large unbuffered
SSI documents"
0dca2f1722 is described below
commit 0dca2f1722a81f586c0db4c63e1df2a60ca286eb
Author: remm <[email protected]>
AuthorDate: Mon Oct 19 21:14:58 2026 +0200
Revert "Keep the Last-Modified header for large unbuffered SSI
documents"
Set last-modifed as best effort.
This reverts commit 363ec9f0d3c8a9e8518c05473ababc419efae608.
---
java/org/apache/catalina/ssi/SSIServlet.java | 12 ++-----
test/org/apache/catalina/ssi/TestSsiServlet.java | 42 ------------------------
2 files changed, 3 insertions(+), 51 deletions(-)
diff --git a/java/org/apache/catalina/ssi/SSIServlet.java
b/java/org/apache/catalina/ssi/SSIServlet.java
index 8281689b87..cd3a82fdfc 100644
--- a/java/org/apache/catalina/ssi/SSIServlet.java
+++ b/java/org/apache/catalina/ssi/SSIServlet.java
@@ -211,15 +211,9 @@ public class SSIServlet extends HttpServlet {
}
try (BufferedReader bufferedReader = new BufferedReader(isr)) {
- // Set the header from the source before the output is generated.
In the
- // unbuffered mode a response larger than the response buffer is
committed
- // while processing, after which setting the header is silently
ignored.
- long sourceLastModified = resourceInfo.getLastModified();
- if (sourceLastModified > 0) {
- res.setDateHeader("last-modified", sourceLastModified);
- }
- long lastModified = ssiProcessor.process(bufferedReader,
sourceLastModified, printWriter);
- if (lastModified > sourceLastModified && !res.isCommitted()) {
+ long lastModified = ssiProcessor.process(bufferedReader,
resourceInfo.getLastModified(), printWriter);
+ // Setting last-modified as best effort
+ if (lastModified > 0) {
res.setDateHeader("last-modified", lastModified);
}
if (stringWriter != null) {
diff --git a/test/org/apache/catalina/ssi/TestSsiServlet.java
b/test/org/apache/catalina/ssi/TestSsiServlet.java
index 3599530415..ef50aaf5ba 100644
--- a/test/org/apache/catalina/ssi/TestSsiServlet.java
+++ b/test/org/apache/catalina/ssi/TestSsiServlet.java
@@ -77,48 +77,6 @@ public class TestSsiServlet extends TomcatBaseTest {
}
- @Test
- public void testLargeDocumentLastModifiedHeader() throws Exception {
- // A document larger than the response buffer commits the unbuffered
- // response while the output is being generated. The Last-Modified
- // header must be set before that happens.
- Tomcat tomcat = getTomcatInstance();
-
- File appDir = new File(getTemporaryDirectory(), "ssi-large");
- Assert.assertTrue(appDir.mkdirs() || appDir.isDirectory());
- addDeleteOnTearDown(appDir);
- File doc = new File(appDir, "large.shtml");
- try (Writer writer = new OutputStreamWriter(new FileOutputStream(doc),
StandardCharsets.ISO_8859_1)) {
- writer.write("X".repeat(20000));
- writer.write("<!--#flastmod file=\"large.shtml\" -->TAIL");
- }
-
- Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
- Tomcat.addServlet(ctxt, "ssi", new SSIServlet());
- ctxt.addServletMapping("*.shtml", "ssi");
-
- tomcat.start();
-
- Map<String,List<String>> resHeaders = new HashMap<>();
- String path = "http://localhost:" + getPort() + "/large.shtml";
- ByteChunk out = new ByteChunk();
-
- int rc = getUrl(path, out, resHeaders);
- Assert.assertEquals(HttpServletResponse.SC_OK, rc);
- String body = new String(out.getBuffer(), 0, out.getLength(),
StandardCharsets.ISO_8859_1);
- Assert.assertTrue(body.endsWith("TAIL"));
- // Headers are case-insensitive. SSIServlet uses the lower-case name.
- String lastModified = null;
- for (Map.Entry<String,List<String>> header : resHeaders.entrySet()) {
- if ("Last-Modified".equalsIgnoreCase(header.getKey())) {
- Assert.assertEquals(1, header.getValue().size());
- lastModified = header.getValue().get(0);
- }
- }
- Assert.assertNotNull(lastModified);
- }
-
-
@Test
public void testBadConditionalExpressionReportsError() throws Exception {
// A conditional directive with an expression that cannot be parsed
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]