Skip to content

Commit 889305f

Browse files
committed
Better handling of duplicate content-length
1 parent 28d42b4 commit 889305f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

java/org/apache/catalina/ha/backend/TcpSender.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,21 @@ public int send(String mess) throws Exception {
185185
// read all the headers.
186186
String header = connectionReaders[i].readLine();
187187
int contentLength = 0;
188+
boolean contentLengthSeen = false;
188189
while (header != null && !header.isEmpty()) {
189190
int colon = header.indexOf(':');
190191
if (colon >= 0) {
191192
String headerName = header.substring(0, colon).trim();
192193
String headerValue = header.substring(colon + 1).trim();
193194
if ("content-length".equalsIgnoreCase(headerName)) {
194-
if (contentLength > 0) {
195+
if (contentLengthSeen) {
195196
log.error(sm.getString("tcpSender.duplicateContentLength"));
196197
close(i);
197198
// Clear any content length if one has been read.
198199
contentLength = 0;
199200
break;
201+
} else {
202+
contentLengthSeen = true;
200203
}
201204
try {
202205
contentLength = Integer.parseInt(headerValue);

0 commit comments

Comments
 (0)