This is an automated email from the ASF dual-hosted git repository. markt 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 46d974a243 Additional case where content length can be set 46d974a243 is described below commit 46d974a243e645a1942c87161803df1a8422db7a 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 44178ff4bf..7473aac51a 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 438fc1a234..a4f8ed08f9 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