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
commit 7d9cacdfc2e073ef4b1493d14f5c8f9f47a00c7f Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed May 24 19:38:36 2023 +0100 Don't set 'C-L: 0' for HEAD requests if Servlet doesn't specify C-L --- java/org/apache/catalina/connector/OutputBuffer.java | 6 +++--- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/connector/OutputBuffer.java b/java/org/apache/catalina/connector/OutputBuffer.java index 62966c653b..0e5bd6659e 100644 --- a/java/org/apache/catalina/connector/OutputBuffer.java +++ b/java/org/apache/catalina/connector/OutputBuffer.java @@ -232,9 +232,9 @@ public class OutputBuffer extends Writer { flushCharBuffer(); } - if ((!coyoteResponse.isCommitted()) && (coyoteResponse.getContentLengthLong() == -1)) { - // If this didn't cause a commit of the response, the final content - // length can be calculated. + if (!coyoteResponse.isCommitted() && coyoteResponse.getContentLengthLong() == -1 && + !coyoteResponse.getRequest().method().equals("HEAD")) { + // If this didn't cause a commit of the response, the final content length can be calculated. if (!coyoteResponse.isCommitted()) { coyoteResponse.setContentLength(bb.remaining()); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index d1fe84b1d2..d7cc56b496 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -124,6 +124,11 @@ file names in directory listings when using XML output. Based on pull request <pr>621</pr> by Alex Kachanov. (markt) </fix> + <fix> + When processing a HEAD request, do not set an HTTP response header for + Content-Length with the value zero if the Servlet does not set the + header. (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