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 62d73af060 Better handling of duplicate content-length
62d73af060 is described below

commit 62d73af0600dadaba07b4feb496cc1086a78930e
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Jun 24 22:52:27 2026 +0100

    Better handling of duplicate content-length
---
 java/org/apache/catalina/ha/backend/TcpSender.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/ha/backend/TcpSender.java 
b/java/org/apache/catalina/ha/backend/TcpSender.java
index 26af09243a..8b13950894 100644
--- a/java/org/apache/catalina/ha/backend/TcpSender.java
+++ b/java/org/apache/catalina/ha/backend/TcpSender.java
@@ -185,18 +185,21 @@ public class TcpSender implements Sender {
                 // read all the headers.
                 String header = connectionReaders[i].readLine();
                 int contentLength = 0;
+                boolean contentLengthSeen = false;
                 while (header != null && !header.isEmpty()) {
                     int colon = header.indexOf(':');
                     if (colon >= 0) {
                         String headerName = header.substring(0, colon).trim();
                         String headerValue = header.substring(colon + 
1).trim();
                         if ("content-length".equalsIgnoreCase(headerName)) {
-                            if (contentLength > 0) {
+                            if (contentLengthSeen) {
                                 
log.error(sm.getString("tcpSender.duplicateContentLength"));
                                 close(i);
                                 // Clear any content length if one has been 
read.
                                 contentLength = 0;
                                 break;
+                            } else {
+                                contentLengthSeen = true;
                             }
                             try {
                                 contentLength = Integer.parseInt(headerValue);


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

Reply via email to