This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new aac6a36de6 Revert "Keep the Last-Modified header for large unbuffered 
SSI documents"
aac6a36de6 is described below

commit aac6a36de6cd7df1189d653a2ce1d43a3d176b82
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 | 46 ------------------------
 2 files changed, 3 insertions(+), 55 deletions(-)

diff --git a/java/org/apache/catalina/ssi/SSIServlet.java 
b/java/org/apache/catalina/ssi/SSIServlet.java
index d4f4993650..0ef4300785 100644
--- a/java/org/apache/catalina/ssi/SSIServlet.java
+++ b/java/org/apache/catalina/ssi/SSIServlet.java
@@ -209,15 +209,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 45f9c08089..fb370b957a 100644
--- a/test/org/apache/catalina/ssi/TestSsiServlet.java
+++ b/test/org/apache/catalina/ssi/TestSsiServlet.java
@@ -77,52 +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)) {
-            StringBuilder outStr = new StringBuilder();
-            for (int i = 0; i < 20000; i++) {
-                outStr.append("X");
-            }
-            writer.write(outStr.toString());
-            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]

Reply via email to