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 2019/04/08 22:00:50 UTC

[tomcat] branch master updated: Additional fix required for async I/O and HTTP/2 'swallow output'

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 4cfe667  Additional fix required for async I/O and HTTP/2 'swallow output'
4cfe667 is described below

commit 4cfe66798144b4dd3cac5b13d9059857a91c3443
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Apr 8 23:00:13 2019 +0100

    Additional fix required for async I/O and HTTP/2 'swallow output'
---
 java/org/apache/coyote/http2/Stream.java          | 15 ++++++++++++---
 java/org/apache/coyote/http2/StreamProcessor.java |  8 ++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 7337eb9..0bb12a0 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -607,10 +607,10 @@ class Stream extends AbstractStream implements HeaderEmitter {
 
 
     final void receivedEndOfStream() throws ConnectionException {
-        long contentLengthHeader = coyoteRequest.getContentLengthLong();
-        if (contentLengthHeader > -1 && contentLengthReceived != contentLengthHeader) {
+        if (isContentLengthInconsistent()) {
             throw new ConnectionException(sm.getString("stream.header.contentLength",
-                    getConnectionId(), getIdentifier(), Long.valueOf(contentLengthHeader),
+                    getConnectionId(), getIdentifier(),
+                    Long.valueOf(coyoteRequest.getContentLengthLong()),
                     Long.valueOf(contentLengthReceived)), Http2Error.PROTOCOL_ERROR);
         }
         state.receivedEndOfStream();
@@ -620,6 +620,15 @@ class Stream extends AbstractStream implements HeaderEmitter {
     }
 
 
+    final boolean isContentLengthInconsistent() {
+        long contentLengthHeader = coyoteRequest.getContentLengthLong();
+        if (contentLengthHeader > -1 && contentLengthReceived != contentLengthHeader) {
+            return true;
+        }
+        return false;
+    }
+
+
     final void sentHeaders() {
         state.sentHeaders();
     }
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java
index 5d1e60d..1e8f6a7 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -417,6 +417,14 @@ class StreamProcessor extends AbstractProcessor {
 
     private void endRequest() throws IOException {
         if (!stream.isInputFinished() && getErrorState().isIoAllowed()) {
+            if (handler.hasAsyncIO() && !stream.isContentLengthInconsistent()) {
+                // Need an additional checks for asyncIO as the end of stream
+                // might have been set on the header frame but not processed
+                // yet. Checking for this here so the extra processing only
+                // occurs on the potential error condition rather than on every
+                // request.
+                return;
+            }
             // The request has been processed but the request body has not been
             // fully read. This typically occurs when Tomcat rejects an upload
             // of some form (e.g. PUT or POST). Need to tell the client not to


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