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

markt-asf 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 318e5766bb Review "Report a content length of Integer.MAX_VALUE as an 
int"
318e5766bb is described below

commit 318e5766bb08e5c9a6afec74f7c5cc5482da1d70
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 30 20:15:01 2026 +0000

    Review "Report a content length of Integer.MAX_VALUE as an int"
    
    Improve handling for content length above Integer.MAX_VALUE
---
 java/org/apache/catalina/connector/OutputBuffer.java |  2 +-
 java/org/apache/catalina/connector/Response.java     | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index 12d463a941..c39e2ad280 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -435,7 +435,7 @@ public class OutputBuffer extends Writer {
 
     private void updateBytesWritten(int increment) throws IOException {
         bytesWritten += increment;
-        int contentLength = coyoteResponse.getContentLength();
+        long contentLength = coyoteResponse.getContentLengthLong();
 
         /*
          * Handle the requirements of section 5.7 of the Servlet specification 
- Closure of the Response Object.
diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index e9b06208fc..2d7a29a6c7 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -269,7 +269,7 @@ public class Response implements HttpServletResponse {
      */
     public boolean isAppCommitted() {
         return this.appCommitted || isCommitted() || isSuspended() ||
-                ((getContentLength() > 0) && (getContentWritten() >= 
getContentLength()));
+                ((getContentLengthLong() > 0) && (getContentWritten() >= 
getContentLengthLong()));
     }
 
 
@@ -435,6 +435,16 @@ public class Response implements HttpServletResponse {
     }
 
 
+    /**
+     * Get the content length that was set or calculated for this response as 
a long.
+     *
+     * @return the content length that was set or calculated for this response
+     */
+    public long getContentLengthLong() {
+        return getCoyoteResponse().getContentLengthLong();
+    }
+
+
     @Override
     public String getContentType() {
         return getCoyoteResponse().getContentType();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to