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 2017/05/09 20:03:22 UTC
[31/50] httpcomponents-core git commit: Request output if request
execution handler is not done (has subsequent requests)
Request output if request execution handler is not done (has subsequent requests)
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.2.x@1477537 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/a8c8e4e8
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/a8c8e4e8
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/a8c8e4e8
Branch: refs/heads/4.2.x
Commit: a8c8e4e83df2e4676e64b858804aabd66dbb8942
Parents: 908b8dd
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue Apr 30 10:33:00 2013 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Apr 30 10:33:00 2013 +0000
----------------------------------------------------------------------
.../nio/protocol/HttpAsyncRequestExecutor.java | 3 +++
.../protocol/TestHttpAsyncRequestExecutor.java | 21 ++++++++++++++++++++
2 files changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a8c8e4e8/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
index 282fc72..b064ecd 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
@@ -373,6 +373,9 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
}
handler.responseCompleted(context);
state.reset();
+ if (!handler.isDone()) {
+ conn.requestOutput();
+ }
}
private boolean canResponseHaveBody(final HttpRequest request, final HttpResponse response) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a8c8e4e8/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
index 76a33b2..89a867f 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
@@ -478,6 +478,7 @@ public class TestHttpAsyncRequestExecutor {
state.setRequest(request);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
state.setResponse(response);
+ Mockito.when(this.exchangeHandler.isDone()).thenReturn(Boolean.TRUE);
this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
Mockito.when(this.reuseStrategy.keepAlive(response, this.exchangeContext)).thenReturn(true);
@@ -493,6 +494,26 @@ public class TestHttpAsyncRequestExecutor {
}
@Test
+ public void testResponseContentOutputCompletedHandlerNotDone() throws Exception {
+ final State state = new HttpAsyncRequestExecutor.State();
+ final HttpRequest request = new BasicHttpRequest("GET", "/");
+ state.setRequest(request);
+ final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+ state.setResponse(response);
+ Mockito.when(this.exchangeHandler.isDone()).thenReturn(Boolean.FALSE);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
+ Mockito.when(this.decoder.isCompleted()).thenReturn(Boolean.TRUE);
+
+ this.protocolHandler.inputReady(this.conn, this.decoder);
+
+ Assert.assertEquals(MessageState.READY, state.getRequestState());
+ Assert.assertEquals(MessageState.READY, state.getResponseState());
+ Mockito.verify(this.exchangeHandler).consumeContent(this.decoder, this.conn);
+ Mockito.verify(this.conn).requestOutput();
+ }
+
+ @Test
public void testResponseInvalidState() throws Exception {
State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");