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 fefe4de  Fix long content-length handling for doHead()
fefe4de is described below

commit fefe4de781449493000a633488aa11198434cf3e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 3 18:57:02 2021 +0100

    Fix long content-length handling for doHead()
---
 java/jakarta/servlet/http/HttpServlet.java | 6 +++---
 webapps/docs/changelog.xml                 | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/java/jakarta/servlet/http/HttpServlet.java 
b/java/jakarta/servlet/http/HttpServlet.java
index 77e8c62..86a5a7b 100644
--- a/java/jakarta/servlet/http/HttpServlet.java
+++ b/java/jakarta/servlet/http/HttpServlet.java
@@ -823,7 +823,7 @@ public abstract class HttpServlet extends GenericServlet {
                 if (writer != null) {
                     writer.flush();
                 }
-                super.setContentLength(noBody.getContentLength());
+                super.setContentLengthLong(noBody.getContentLength());
             }
         }
 
@@ -899,13 +899,13 @@ public abstract class HttpServlet extends GenericServlet {
 
         private final HttpServletResponse response;
         private boolean flushed = false;
-        private int contentLength = 0;
+        private long contentLength = 0;
 
         private NoBodyOutputStream(HttpServletResponse response) {
             this.response = response;
         }
 
-        private int getContentLength() {
+        private long getContentLength() {
             return contentLength;
         }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f56b524..cd79722 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -164,6 +164,12 @@
         Refactor principal handling in <code>UserDatabaseRealm</code> using
         an inner class that extends <code>GenericPrincipal</code>. (remm)
       </update>
+      <fix>
+        Enable the default <code>doHead())</code> implementation in
+        <code>HttpServlet</code> to correctly handle responses where the 
content
+        length needs to be represented as a long since it is larger than the
+        maximum value that can be represented by an int. (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