This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 11bd3b5 Improve handling of aborted uploads 11bd3b5 is described below commit 11bd3b5f68e93884e1b3b10a919a927d9bbfc904 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Jun 5 09:53:11 2020 +0100 Improve handling of aborted uploads --- java/org/apache/coyote/http11/Http11Processor.java | 16 ++++++++++++++++ webapps/docs/changelog.xml | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 203c16a..409cd8c 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -769,6 +769,18 @@ public class Http11Processor extends AbstractProcessor { } + private void checkMaxSwallowSize() { + if (request.getContentLengthLong() > 0 && + (request.getContentLengthLong() - request.getBytesRead() > protocol.getMaxSwallowSize())) { + // There is more data to swallow than Tomcat will accept so the + // connection is going to be closed. Disable keep-alive which will + // trigger adding the "Connection: close" header if not already + // present. + keepAlive = false; + } + } + + private void prepareRequestProtocol() { MessageBytes protocolMB = request.protocol(); @@ -1150,6 +1162,10 @@ public class Http11Processor extends AbstractProcessor { // Connection header. checkExpectationAndResponseStatus(); + // This may disable keep-alive if there is more body to swallow + // than the configuration allows + checkMaxSwallowSize(); + // If we know that the request is bad this early, add the // Connection: close header. if (keepAlive && statusDropsConnection(statusCode)) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 818da19..1394312 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -55,6 +55,15 @@ </add> </changelog> </subsection> + <subsection name="Coyote"> + <changelog> + <add> + Include a <code>Connection: close</code> HTTP header when committing a + response and it is known that the <code>maxSwallowSize</code> limit is + going to be exceeded. (markt) + </add> + </changelog> + </subsection> </section> <section name="Tomcat 8.5.56 (markt)" rtext="release in progress"> <subsection name="Catalina"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org