You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/06/03 17:58:16 UTC

[tomcat] branch 8.5.x updated: Fix long content-length handling for doHead()

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

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 939d6cc  Fix long content-length handling for doHead()
939d6cc is described below

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

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

diff --git a/java/javax/servlet/http/HttpServlet.java b/java/javax/servlet/http/HttpServlet.java
index 16c346d..3b5b6ad 100644
--- a/java/javax/servlet/http/HttpServlet.java
+++ b/java/javax/servlet/http/HttpServlet.java
@@ -779,7 +779,7 @@ public abstract class HttpServlet extends GenericServlet {
                 if (writer != null) {
                     writer.flush();
                 }
-                super.setContentLength(noBody.getContentLength());
+                super.setContentLengthLong(noBody.getContentLength());
             }
         }
 
@@ -855,13 +855,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 8be9dfb..e2b2aae 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -152,6 +152,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org