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/11/12 14:50:11 UTC

httpcomponents-client git commit: Fixed handling of request configuration by async clients

Repository: httpcomponents-client
Updated Branches:
  refs/heads/master 7c0a1127b -> 1577356f3


Fixed handling of request configuration by async clients


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/1577356f
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/1577356f
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/1577356f

Branch: refs/heads/master
Commit: 1577356f37103838c94214908cceb9e5ca8beea7
Parents: 7c0a112
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Thu Nov 9 11:26:51 2017 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Nov 9 11:26:51 2017 +0100

----------------------------------------------------------------------
 .../testing/async/TestAsyncRedirects.java       | 14 ++---
 .../testing/async/TestClientAuthentication.java | 12 +---
 .../examples/AsyncClientConnectionEviction.java |  4 +-
 .../http/examples/AsyncClientCustomSSL.java     |  2 +-
 .../examples/AsyncClientHttp1Pipelining.java    |  2 +-
 .../examples/AsyncClientHttp2Multiplexing.java  |  2 +-
 .../http/examples/AsyncClientTlsAlpn.java       |  2 +-
 .../http/async/methods/AsyncRequestBuilder.java | 11 ++--
 .../async/methods/ConfigurableHttpRequest.java  | 63 ++++++++++++++++++++
 .../methods/DefaultAsyncRequestProducer.java    | 53 ----------------
 .../http/async/methods/SimpleHttpRequest.java   |  5 +-
 .../async/methods/SimpleRequestProducer.java    | 13 ++--
 .../impl/async/CloseableHttpAsyncClient.java    |  2 +-
 .../impl/async/InternalHttpAsyncClient.java     | 16 +++--
 .../http/impl/async/MinimalHttpAsyncClient.java | 22 +++----
 15 files changed, 112 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestAsyncRedirects.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestAsyncRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestAsyncRedirects.java
index cacbef1..83c429e 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestAsyncRedirects.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestAsyncRedirects.java
@@ -42,8 +42,6 @@ import org.apache.hc.client5.http.CircularRedirectException;
 import org.apache.hc.client5.http.RedirectException;
 import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
 import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
-import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
-import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
 import org.apache.hc.client5.http.config.RequestConfig;
 import org.apache.hc.client5.http.cookie.BasicCookieStore;
 import org.apache.hc.client5.http.cookie.CookieStore;
@@ -455,9 +453,9 @@ public class TestAsyncRedirects extends IntegrationTestBase {
                 .setCircularRedirectsAllowed(true)
                 .setMaxRedirects(5).build();
         try {
-            final Future<SimpleHttpResponse> future = httpclient.execute(
-                    SimpleRequestProducer.create(SimpleHttpRequest.get(target, "/circular-oldlocation/"), config),
-                    SimpleResponseConsumer.create(), null);
+            final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/circular-oldlocation/");
+            request.setConfig(config);
+            final Future<SimpleHttpResponse> future = httpclient.execute(request, null);
             future.get();
         } catch (final ExecutionException e) {
             Assert.assertTrue(e.getCause() instanceof RedirectException);
@@ -481,9 +479,9 @@ public class TestAsyncRedirects extends IntegrationTestBase {
                 .setCircularRedirectsAllowed(false)
                 .build();
         try {
-            final Future<SimpleHttpResponse> future = httpclient.execute(
-                    SimpleRequestProducer.create(SimpleHttpRequest.get(target, "/circular-oldlocation/"), config),
-                    SimpleResponseConsumer.create(), null);
+            final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/circular-oldlocation/");
+            request.setConfig(config);
+            final Future<SimpleHttpResponse> future = httpclient.execute(request, null);
             future.get();
         } catch (final ExecutionException e) {
             Assert.assertTrue(e.getCause() instanceof CircularRedirectException);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java
index 606e66a..7841420 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java
@@ -35,8 +35,6 @@ import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
 import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
-import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
-import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
 import org.apache.hc.client5.http.auth.AuthChallenge;
 import org.apache.hc.client5.http.auth.AuthScheme;
 import org.apache.hc.client5.http.auth.AuthSchemeProvider;
@@ -45,7 +43,6 @@ import org.apache.hc.client5.http.auth.ChallengeType;
 import org.apache.hc.client5.http.auth.Credentials;
 import org.apache.hc.client5.http.auth.CredentialsStore;
 import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
-import org.apache.hc.client5.http.classic.methods.HttpGet;
 import org.apache.hc.client5.http.config.RequestConfig;
 import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy;
 import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
@@ -547,12 +544,9 @@ public class TestClientAuthentication extends IntegrationTestBase {
         context.setCredentialsProvider(credsProvider);
 
         for (int i = 0; i < 10; i++) {
-            final HttpGet httpget = new HttpGet("/");
-            httpget.setConfig(config);
-            final Future<SimpleHttpResponse> future = httpclient.execute(
-                    SimpleRequestProducer.create(SimpleHttpRequest.get(target, "/"), config),
-                    SimpleResponseConsumer.create(),
-                    context, null);
+            final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/");
+            request.setConfig(config);
+            final Future<SimpleHttpResponse> future = httpclient.execute(request, context, null);
             final SimpleHttpResponse response = future.get();
             Assert.assertNotNull(response);
             Assert.assertEquals(HttpStatus.SC_OK, response.getCode());

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
index d9dc724..2c46a58 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
@@ -66,7 +66,7 @@ public class AsyncClientConnectionEviction {
 
         final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/");
         final Future<SimpleHttpResponse> future1 = client.execute(
-                SimpleRequestProducer.create(request, null),
+                SimpleRequestProducer.create(request),
                 SimpleResponseConsumer.create(),
                 new FutureCallback<SimpleHttpResponse>() {
 
@@ -95,7 +95,7 @@ public class AsyncClientConnectionEviction {
         // Previous connection should get evicted from the pool by now
 
         final Future<SimpleHttpResponse> future2 = client.execute(
-                SimpleRequestProducer.create(request, null),
+                SimpleRequestProducer.create(request),
                 SimpleResponseConsumer.create(),
                 new FutureCallback<SimpleHttpResponse>() {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
index a95867a..bc86d50 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
@@ -98,7 +98,7 @@ public class AsyncClientCustomSSL {
 
             final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
             final Future<SimpleHttpResponse> future = client.execute(
-                    SimpleRequestProducer.create(request, null),
+                    SimpleRequestProducer.create(request),
                     SimpleResponseConsumer.create(),
                     clientContext,
                     new FutureCallback<SimpleHttpResponse>() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
index ccf204f..9e10f30 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
@@ -69,7 +69,7 @@ public class AsyncClientHttp1Pipelining {
             for (final String requestUri: requestUris) {
                 final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
                 endpoint.execute(
-                        SimpleRequestProducer.create(request, null),
+                        SimpleRequestProducer.create(request),
                         SimpleResponseConsumer.create(),
                         new FutureCallback<SimpleHttpResponse>() {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
index 1c1bf96..f908461 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
@@ -70,7 +70,7 @@ public class AsyncClientHttp2Multiplexing {
             for (final String requestUri: requestUris) {
                 final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
                 endpoint.execute(
-                        SimpleRequestProducer.create(request, null),
+                        SimpleRequestProducer.create(request),
                         SimpleResponseConsumer.create(),
                         new FutureCallback<SimpleHttpResponse>() {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
index 7898e1a..77bb55c 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
@@ -100,7 +100,7 @@ public class AsyncClientTlsAlpn {
 
             final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
             final Future<SimpleHttpResponse> future = client.execute(
-                    SimpleRequestProducer.create(request, null),
+                    SimpleRequestProducer.create(request),
                     SimpleResponseConsumer.create(),
                     clientContext,
                     new FutureCallback<SimpleHttpResponse>() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
index 0ec948f..c07a42e 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
@@ -43,11 +43,11 @@ import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.NameValuePair;
 import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.http.message.BasicNameValuePair;
 import org.apache.hc.core5.http.message.HeaderGroup;
 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
 import org.apache.hc.core5.http.nio.AsyncRequestProducer;
+import org.apache.hc.core5.http.nio.BasicRequestProducer;
 import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
 import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
 import org.apache.hc.core5.net.URIBuilder;
@@ -429,16 +429,17 @@ public class AsyncRequestBuilder {
                 }
             }
         }
-        final BasicHttpRequest request = host != null ?
-                new BasicHttpRequest(method, host, !TextUtils.isBlank(path) ? path : "/") :
-                new BasicHttpRequest(method, uri != null ? uri : URI.create("/"));
+        final ConfigurableHttpRequest request = host != null ?
+                new ConfigurableHttpRequest(method, host, !TextUtils.isBlank(path) ? path : "/") :
+                new ConfigurableHttpRequest(method, uri != null ? uri : URI.create("/"));
         if (this.headergroup != null) {
             request.setHeaders(this.headergroup.getAllHeaders());
         }
         if (version != null) {
             request.setVersion(version);
         }
-        return new DefaultAsyncRequestProducer(request, entityProducerCopy, config);
+        request.setConfig(config);
+        return new BasicRequestProducer(request, entityProducerCopy);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/ConfigurableHttpRequest.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/ConfigurableHttpRequest.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/ConfigurableHttpRequest.java
new file mode 100644
index 0000000..19d7aac
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/ConfigurableHttpRequest.java
@@ -0,0 +1,63 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.client5.http.async.methods;
+
+import java.net.URI;
+
+import org.apache.hc.client5.http.config.Configurable;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+
+public class ConfigurableHttpRequest extends BasicHttpRequest implements Configurable {
+
+    private RequestConfig requestConfig;
+
+    public ConfigurableHttpRequest(final String method, final String path) {
+        super(method, path);
+    }
+
+    public ConfigurableHttpRequest(final String method, final HttpHost host, final String path) {
+        super(method, host, path);
+    }
+
+    public ConfigurableHttpRequest(final String method, final URI requestUri) {
+        super(method, requestUri);
+    }
+
+    @Override
+    public RequestConfig getConfig() {
+        return requestConfig;
+    }
+
+    public void setConfig(final RequestConfig requestConfig) {
+        this.requestConfig = requestConfig;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/DefaultAsyncRequestProducer.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/DefaultAsyncRequestProducer.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/DefaultAsyncRequestProducer.java
deleted file mode 100644
index 6491981..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/DefaultAsyncRequestProducer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-package org.apache.hc.client5.http.async.methods;
-
-import org.apache.hc.client5.http.config.Configurable;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.nio.AsyncEntityProducer;
-import org.apache.hc.core5.http.nio.BasicRequestProducer;
-
-public class DefaultAsyncRequestProducer extends BasicRequestProducer implements Configurable {
-
-    private final RequestConfig config;
-
-    public DefaultAsyncRequestProducer(final HttpRequest request, final AsyncEntityProducer entityProducer, final RequestConfig config) {
-        super(request, entityProducer);
-        this.config = config;
-    }
-
-    public DefaultAsyncRequestProducer(final HttpRequest request, final AsyncEntityProducer entityProducer) {
-        this(request, entityProducer, null);
-    }
-
-    @Override
-    public RequestConfig getConfig() {
-        return config;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
index 69238d9..7fcd3c2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
@@ -31,15 +31,16 @@ import java.net.URI;
 import java.util.Iterator;
 
 import org.apache.hc.client5.http.StandardMethods;
+import org.apache.hc.client5.http.config.RequestConfig;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.util.Args;
 
-public final class SimpleHttpRequest extends BasicHttpRequest {
+public final class SimpleHttpRequest extends ConfigurableHttpRequest {
 
+    private RequestConfig requestConfig;
     private SimpleBody body;
 
     public static SimpleHttpRequest get(final URI requestUri) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java
index ffa2f50..823959c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java
@@ -26,20 +26,19 @@
  */
 package org.apache.hc.client5.http.async.methods;
 
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
+import org.apache.hc.core5.http.nio.BasicRequestProducer;
 import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
 import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
 import org.apache.hc.core5.util.Args;
 
-public final class SimpleRequestProducer extends DefaultAsyncRequestProducer {
+public final class SimpleRequestProducer extends BasicRequestProducer {
 
-    SimpleRequestProducer(final HttpRequest request, final AsyncEntityProducer entityProducer, final RequestConfig requestConfig) {
-        super(request, entityProducer, requestConfig);
+    SimpleRequestProducer(final SimpleHttpRequest request, final AsyncEntityProducer entityProducer) {
+        super(request, entityProducer);
     }
 
-    public static SimpleRequestProducer create(final SimpleHttpRequest request, final RequestConfig requestConfig) {
+    public static SimpleRequestProducer create(final SimpleHttpRequest request) {
         Args.notNull(request, "Request");
         final SimpleBody body = request.getBody();
         final AsyncEntityProducer entityProducer;
@@ -52,7 +51,7 @@ public final class SimpleRequestProducer extends DefaultAsyncRequestProducer {
         } else {
             entityProducer = null;
         }
-        return new SimpleRequestProducer(request, entityProducer, requestConfig);
+        return new SimpleRequestProducer(request, entityProducer);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
index 56bcd93..e153f21 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
@@ -88,7 +88,7 @@ public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Close
             final FutureCallback<SimpleHttpResponse> callback) {
         Args.notNull(request, "Request");
         final BasicFuture<SimpleHttpResponse> future = new BasicFuture<>(callback);
-        execute(SimpleRequestProducer.create(request, null), SimpleResponseConsumer.create(), context, new FutureCallback<SimpleHttpResponse>() {
+        execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), context, new FutureCallback<SimpleHttpResponse>() {
 
             @Override
             public void completed(final SimpleHttpResponse response) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
index 0a9f3c9..352f70c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
@@ -153,15 +153,6 @@ class InternalHttpAsyncClient extends AbstractHttpAsyncClientBase {
         final BasicFuture<T> future = new BasicFuture<>(callback);
         try {
             final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
-            RequestConfig requestConfig = null;
-            if (requestProducer instanceof Configurable) {
-                requestConfig = ((Configurable) requestProducer).getConfig();
-            }
-            if (requestConfig != null) {
-                clientContext.setRequestConfig(requestConfig);
-            }
-
             requestProducer.sendRequest(new RequestChannel() {
 
                 @Override
@@ -169,6 +160,13 @@ class InternalHttpAsyncClient extends AbstractHttpAsyncClientBase {
                         final HttpRequest request,
                         final EntityDetails entityDetails) throws HttpException, IOException {
 
+                    RequestConfig requestConfig = null;
+                    if (request instanceof Configurable) {
+                        requestConfig = ((Configurable) request).getConfig();
+                    }
+                    if (requestConfig != null) {
+                        clientContext.setRequestConfig(requestConfig);
+                    }
                     final HttpHost target = routePlanner.determineTargetHost(request, clientContext);
                     final HttpRoute route = routePlanner.determineRoute(target, clientContext);
                     final String exchangeId = String.format("ex-%08X", ExecSupport.getNextExecNumber());

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1577356f/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
index f4ce0a6..72b050a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
@@ -202,25 +202,25 @@ public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
             final HttpContext context,
             final FutureCallback<T> callback) {
         ensureRunning();
-        final HttpClientContext clientContext = HttpClientContext.adapt(context);
-        RequestConfig requestConfig = null;
-        if (requestProducer instanceof Configurable) {
-            requestConfig = ((Configurable) requestProducer).getConfig();
-        }
-        if (requestConfig != null) {
-            clientContext.setRequestConfig(requestConfig);
-        } else {
-            requestConfig = clientContext.getRequestConfig();
-        }
         final ComplexFuture<T> resultFuture = new ComplexFuture<>(callback);
+        final HttpClientContext clientContext = HttpClientContext.adapt(context);
         try {
-            final Timeout connectTimeout = requestConfig.getConnectTimeout();
             requestProducer.sendRequest(new RequestChannel() {
 
                 @Override
                 public void sendRequest(
                         final HttpRequest request,
                         final EntityDetails entityDetails) throws HttpException, IOException {
+                    RequestConfig requestConfig = null;
+                    if (request instanceof Configurable) {
+                        requestConfig = ((Configurable) request).getConfig();
+                    }
+                    if (requestConfig != null) {
+                        clientContext.setRequestConfig(requestConfig);
+                    } else {
+                        requestConfig = clientContext.getRequestConfig();
+                    }
+                    final Timeout connectTimeout = requestConfig.getConnectTimeout();
                     final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme());
                     final Future<AsyncConnectionEndpoint> leaseFuture = leaseEndpoint(target, connectTimeout, clientContext,
                             new FutureCallback<AsyncConnectionEndpoint>() {