You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2025/02/17 17:30:43 UTC

(httpcomponents-core) 02/02: Bug-fix: Corrected message stream termination by the async HTTP/1.1 protocol handler when the connection has been half-closed by the opposite endpoint

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

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 841f6acbbccf705846ea9da2753b12292afb0162
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Feb 17 15:51:01 2025 +0100

    Bug-fix: Corrected message stream termination by the async HTTP/1.1 protocol handler when the connection has been half-closed by the opposite endpoint
---
 .../org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java     | 2 +-
 .../org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
index 18cc5af96..56c57b627 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
@@ -92,10 +92,10 @@ public void requestOutput() {
             @Override
             public void endStream(final List<? extends Header> trailers) throws IOException {
                 requestState = MessageState.COMPLETE;
+                outputChannel.complete(trailers);
                 if (!keepAlive && responseState == MessageState.COMPLETE) {
                     outputChannel.close();
                 }
-                outputChannel.complete(trailers);
             }
 
             @Override
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
index 28f108e31..83e77a9ba 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
@@ -102,8 +102,8 @@ public void requestOutput() {
 
             @Override
             public void endStream(final List<? extends Header> trailers) throws IOException {
-                outputChannel.complete(trailers);
                 responseState = MessageState.COMPLETE;
+                outputChannel.complete(trailers);
                 if (requestState == MessageState.COMPLETE && !keepAlive) {
                     outputChannel.close();
                 }