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

markt 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 7277d5430c Additional case where content length can be set
7277d5430c is described below

commit 7277d5430c6f0b66b0e2ba9baf8d731f9bddf759
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jun 17 10:28:48 2025 +0100

    Additional case where content length can be set
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 2 +-
 webapps/docs/changelog.xml                            | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index d2eea67d17..ded4594c3b 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1074,7 +1074,7 @@ public class DefaultServlet extends HttpServlet {
                     response.setContentType(contentType);
                 }
             }
-            if (resource.isFile() && contentLength >= 0 && (!serveContent || 
ostream != null)) {
+            if (resource.isFile() && contentLength >= 0 && (!serveContent || 
ostream != null || writer != null)) {
                 if (debug > 0) {
                     log("DefaultServlet.serveFile:  contentLength=" + 
contentLength);
                 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ef55820e92..451b16b2f1 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -170,6 +170,11 @@
         Ensure application configured welcome files override the defaults when
         configuring an embedded web application programmatically. (markt)
       </fix>
+      <fix>
+        Allow the default servlet to set the content length when the content
+        length is known, no content has been written and a <code>Writer</code>
+        is being used. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to