This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 18f34374f9 Review "Report a content length of Integer.MAX_VALUE as an
int"
18f34374f9 is described below
commit 18f34374f981edab13ab4b362cb32d1506da5e03
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 22e30036d4..2fe279015b 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -271,7 +271,7 @@ public class Response implements HttpServletResponse {
*/
public boolean isAppCommitted() {
return this.appCommitted || isCommitted() || isSuspended() ||
- ((getContentLength() > 0) && (getContentWritten() >=
getContentLength()));
+ ((getContentLengthLong() > 0) && (getContentWritten() >=
getContentLengthLong()));
}
@@ -437,6 +437,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]