You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/06/05 08:53:46 UTC

[tomcat] branch master updated: Improve handling of aborted uploads

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c304cc  Improve handling of aborted uploads
3c304cc is described below

commit 3c304cc0da9dd413ac4df289299e9ff04c670b17
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 4b6afdb..897c2d9 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -527,6 +527,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();
@@ -913,6 +925,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 0778232..5eed2b7 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 10.0.0-M6 (markt)" rtext="release in progress">
   <subsection name="Catalina">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org