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

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

commit cd828818623572842bcd0a71bfe262ec3d885166
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 c8fa8135a4..c76ace1a74 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1097,7 +1097,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 60c9963338..b85052409f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -111,6 +111,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="Web applications">


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

Reply via email to