You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2025/01/30 21:39:40 UTC
(tomcat) branch 9.0.x updated: Cleanup code paths
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 72c92ef2d0 Cleanup code paths
72c92ef2d0 is described below
commit 72c92ef2d0fd4c2995438a88da873871a88ff9c3
Author: remm <re...@apache.org>
AuthorDate: Thu Jan 30 22:33:16 2025 +0100
Cleanup code paths
No actual changes, but improves test coverage by removing useless
branches.
---
.../coyote/http11/filters/ChunkedInputFilter.java | 26 ++++++++++------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 4621ab82e4..429f1e2586 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -201,30 +201,29 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler
if (available > 2 && (parseState == ParseState.CHUNK_BODY_CRLF || parseState == ParseState.CHUNK_HEADER)) {
if (parseState == ParseState.CHUNK_BODY_CRLF) {
- skipCRLF();
+ if (skipCRLF()) {
+ parseState = ParseState.CHUNK_HEADER;
+ }
}
if (parseState == ParseState.CHUNK_HEADER) {
skipChunkHeader();
}
- available = readChunk.remaining();
// If ending as TRAILER_FIELDS, then the next read will be EOF and available can be > 0
// If ending as CHUNK_HEADER then there's nothing left to read for now
- // If ending as CHUNK_BODY_CRLF, then if there's more than two left, there will be data to read or leading to EOF
+ // If ending as CHUNK_BODY then data is available
+ // If failed, will throw when trying again on the next read for CRLF or header
+ available = readChunk.remaining();
}
if (available == 1 && parseState == ParseState.CHUNK_BODY_CRLF) {
- // Either just the CR or just the LF are left in the buffer. There is no data to read.
- if (!skipCRLF()) {
- available = readChunk.remaining();
- } else {
- available = 0;
- }
+ skipCRLF();
+ // LF to read next, or failed
+ available = readChunk.remaining();
} else if (available == 2 && !crFound && parseState == ParseState.CHUNK_BODY_CRLF) {
// Just CRLF is left in the buffer. There is no data to read.
- if (!skipCRLF()) {
- available = readChunk.remaining();
- } else {
- available = 0;
+ if (skipCRLF()) {
+ parseState = ParseState.CHUNK_HEADER;
}
+ available = readChunk.remaining();
}
if (available == 0) {
@@ -571,7 +570,6 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler
}
crFound = false;
- parseState = ParseState.CHUNK_HEADER;
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org