hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [3/6] httpcomponents-client git commit: Upgraded HttpCore to version 5.0-alpha4
Date Fri, 01 Sep 2017 18:32:14 GMT
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
index 6a1e999..bd61075 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
@@ -53,7 +53,6 @@ import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.ProtocolException;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
-import org.apache.hc.core5.http.io.UriHttpRequestHandlerMapper;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.apache.hc.core5.http.message.BasicHeader;
@@ -120,15 +119,20 @@ public class TestRedirects extends LocalServerTestBase {
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final String uri = request.getRequestUri();
-            if (uri.startsWith("/circular-oldlocation")) {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/circular-location2"));
-            } else if (uri.startsWith("/circular-location2")) {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/circular-oldlocation"));
-            } else {
-                response.setCode(HttpStatus.SC_NOT_FOUND);
+            try {
+                final URI requestURI = request.getUri();
+                final String path = requestURI.getPath();
+                if (path.startsWith("/circular-oldlocation")) {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", "/circular-location2"));
+                } else if (path.startsWith("/circular-location2")) {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", "/circular-oldlocation"));
+                } else {
+                    response.setCode(HttpStatus.SC_NOT_FOUND);
+                }
+            } catch (final URISyntaxException ex) {
+                throw new ProtocolException(ex.getMessage(), ex);
             }
         }
     }
@@ -144,16 +148,21 @@ public class TestRedirects extends LocalServerTestBase {
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final String uri = request.getRequestUri();
-            if (uri.equals("/oldlocation/")) {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/relativelocation/"));
-            } else if (uri.equals("/relativelocation/")) {
-                response.setCode(HttpStatus.SC_OK);
-                final StringEntity entity = new StringEntity("Successful redirect");
-                response.setEntity(entity);
-            } else {
-                response.setCode(HttpStatus.SC_NOT_FOUND);
+            try {
+                final URI requestURI = request.getUri();
+                final String path = requestURI.getPath();
+                if (path.equals("/oldlocation/")) {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", "/relativelocation/"));
+                } else if (path.equals("/relativelocation/")) {
+                    response.setCode(HttpStatus.SC_OK);
+                    final StringEntity entity = new StringEntity("Successful redirect");
+                    response.setEntity(entity);
+                } else {
+                    response.setCode(HttpStatus.SC_NOT_FOUND);
+                }
+            } catch (final URISyntaxException ex) {
+                throw new ProtocolException(ex.getMessage(), ex);
             }
         }
     }
@@ -169,16 +178,21 @@ public class TestRedirects extends LocalServerTestBase {
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final String uri = request.getRequestUri();
-            if (uri.equals("/test/oldlocation")) {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "relativelocation"));
-            } else if (uri.equals("/test/relativelocation")) {
-                response.setCode(HttpStatus.SC_OK);
-                final StringEntity entity = new StringEntity("Successful redirect");
-                response.setEntity(entity);
-            } else {
-                response.setCode(HttpStatus.SC_NOT_FOUND);
+            try {
+                final URI requestURI = request.getUri();
+                final String path = requestURI.getPath();
+                if (path.equals("/test/oldlocation")) {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", "relativelocation"));
+                } else if (path.equals("/test/relativelocation")) {
+                    response.setCode(HttpStatus.SC_OK);
+                    final StringEntity entity = new StringEntity("Successful redirect");
+                    response.setEntity(entity);
+                } else {
+                    response.setCode(HttpStatus.SC_NOT_FOUND);
+                }
+            } catch (final URISyntaxException ex) {
+                throw new ProtocolException(ex.getMessage(), ex);
             }
         }
     }
@@ -194,24 +208,36 @@ public class TestRedirects extends LocalServerTestBase {
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final String uri = request.getRequestUri();
-            if (uri.equals("/rome")) {
-                response.setCode(HttpStatus.SC_OK);
-                final StringEntity entity = new StringEntity("Successful redirect");
-                response.setEntity(entity);
-            } else {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/rome"));
+            try {
+                final URI requestURI = request.getUri();
+                final String path = requestURI.getPath();
+                if (path.equals("/rome")) {
+                    response.setCode(HttpStatus.SC_OK);
+                    final StringEntity entity = new StringEntity("Successful redirect");
+                    response.setEntity(entity);
+                } else {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", "/rome"));
+                }
+            } catch (final URISyntaxException ex) {
+                throw new ProtocolException(ex.getMessage(), ex);
             }
         }
     }
 
-    private static class BogusRedirectService implements HttpRequestHandler {
-        private final String url;
+    interface UriTransformation {
+
+        String rewrite(URI requestUri);
 
-        public BogusRedirectService(final String redirectUrl) {
+    }
+
+    private static class TransformingRedirectService implements HttpRequestHandler {
+
+        private final UriTransformation uriTransformation;
+
+        public TransformingRedirectService(final UriTransformation uriTransformation) {
             super();
-            this.url = redirectUrl;
+            this.uriTransformation = uriTransformation;
         }
 
         @Override
@@ -219,24 +245,28 @@ public class TestRedirects extends LocalServerTestBase {
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final String uri = request.getRequestUri();
-            if (uri.equals("/oldlocation/")) {
-                response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", url));
-            } else if (uri.equals("/relativelocation/")) {
-                response.setCode(HttpStatus.SC_OK);
-                final StringEntity entity = new StringEntity("Successful redirect");
-                response.setEntity(entity);
-            } else {
-                response.setCode(HttpStatus.SC_NOT_FOUND);
+            try {
+                final URI requestURI = request.getUri();
+                final String path = requestURI.getPath();
+                if (path.equals("/oldlocation/")) {
+                    response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
+                    response.addHeader(new BasicHeader("Location", uriTransformation.rewrite(requestURI)));
+                } else if (path.equals("/relativelocation/")) {
+                    response.setCode(HttpStatus.SC_OK);
+                    final StringEntity entity = new StringEntity("Successful redirect");
+                    response.setEntity(entity);
+                } else {
+                    response.setCode(HttpStatus.SC_NOT_FOUND);
+                }
+            } catch (final URISyntaxException ex) {
+                throw new ProtocolException(ex.getMessage(), ex);
             }
         }
     }
 
     @Test
     public void testBasicRedirect300() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_MULTIPLE_CHOICES));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_MULTIPLE_CHOICES));
 
         final HttpHost target = start();
 
@@ -258,8 +288,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect301() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_MOVED_PERMANENTLY));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_MOVED_PERMANENTLY));
 
         final HttpHost target = start();
 
@@ -285,8 +314,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect302() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_MOVED_TEMPORARILY));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_MOVED_TEMPORARILY));
 
         final HttpHost target = start();
 
@@ -305,7 +333,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect302NoLocation() throws Exception {
-        this.serverBootstrap.registerHandler("*", new HttpRequestHandler() {
+        this.server.registerHandler("*", new HttpRequestHandler() {
 
             @Override
             public void handle(
@@ -334,8 +362,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect303() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_SEE_OTHER));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_SEE_OTHER));
 
         final HttpHost target = start();
 
@@ -354,8 +381,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect304() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_NOT_MODIFIED));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_NOT_MODIFIED));
 
         final HttpHost target = start();
 
@@ -374,8 +400,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect305() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_USE_PROXY));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_USE_PROXY));
         final HttpHost target = start();
 
         final HttpClientContext context = HttpClientContext.create();
@@ -393,8 +418,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testBasicRedirect307() throws Exception {
-        this.serverBootstrap.registerHandler("*",
-                new BasicRedirectService(HttpStatus.SC_TEMPORARY_REDIRECT));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_TEMPORARY_REDIRECT));
 
         final HttpHost target = start();
 
@@ -413,7 +437,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test(expected=ClientProtocolException.class)
     public void testMaxRedirectCheck() throws Exception {
-        this.serverBootstrap.registerHandler("*", new CircularRedirectService());
+        this.server.registerHandler("*", new CircularRedirectService());
 
         final HttpHost target = start();
 
@@ -434,7 +458,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test(expected=ClientProtocolException.class)
     public void testCircularRedirect() throws Exception {
-        this.serverBootstrap.registerHandler("*", new CircularRedirectService());
+        this.server.registerHandler("*", new CircularRedirectService());
 
         final HttpHost target = start();
 
@@ -454,7 +478,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testRepeatRequest() throws Exception {
-        this.serverBootstrap.registerHandler("*", new RomeRedirectService());
+        this.server.registerHandler("*", new RomeRedirectService());
 
         final HttpHost target = start();
 
@@ -477,7 +501,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testRepeatRequestRedirect() throws Exception {
-        this.serverBootstrap.registerHandler("*", new RomeRedirectService());
+        this.server.registerHandler("*", new RomeRedirectService());
 
         final HttpHost target = start();
 
@@ -500,7 +524,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testDifferentRequestSameRedirect() throws Exception {
-        this.serverBootstrap.registerHandler("*", new RomeRedirectService());
+        this.server.registerHandler("*", new RomeRedirectService());
 
         final HttpHost target = start();
 
@@ -524,7 +548,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testPostRedirectSeeOther() throws Exception {
-        this.serverBootstrap.registerHandler("*", new BasicRedirectService(HttpStatus.SC_SEE_OTHER));
+        this.server.registerHandler("*", new BasicRedirectService(HttpStatus.SC_SEE_OTHER));
 
         final HttpHost target = start();
 
@@ -545,7 +569,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testRelativeRedirect() throws Exception {
-        this.serverBootstrap.registerHandler("*", new RelativeRedirectService());
+        this.server.registerHandler("*", new RelativeRedirectService());
 
         final HttpHost target = start();
 
@@ -564,7 +588,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testRelativeRedirect2() throws Exception {
-        this.serverBootstrap.registerHandler("*", new RelativeRedirectService2());
+        this.server.registerHandler("*", new RelativeRedirectService2());
 
         final HttpHost target = start();
 
@@ -583,7 +607,14 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test(expected=ClientProtocolException.class)
     public void testRejectBogusRedirectLocation() throws Exception {
-        this.serverBootstrap.registerHandler("*", new BogusRedirectService("xxx://bogus"));
+        this.server.registerHandler("*", new TransformingRedirectService(new UriTransformation() {
+
+            @Override
+            public String rewrite(final URI requestUri) {
+                return "xxx://bogus";
+            }
+
+        }));
 
         final HttpHost target = start();
 
@@ -600,14 +631,15 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test(expected=ClientProtocolException.class)
     public void testRejectInvalidRedirectLocation() throws Exception {
-        final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
-        this.serverBootstrap.setHandlerMapper(reqistry);
+        this.server.registerHandler("*", new TransformingRedirectService(new UriTransformation() {
 
-        final HttpHost target = start();
+            @Override
+            public String rewrite(final URI requestUri) {
+                return "/newlocation/?p=I have spaces";
+            }
 
-        reqistry.register("*",
-                new BogusRedirectService("http://" + target.toHostString() +
-                        "/newlocation/?p=I have spaces"));
+        }));
+        final HttpHost target = start();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -621,7 +653,7 @@ public class TestRedirects extends LocalServerTestBase {
 
     @Test
     public void testRedirectWithCookie() throws Exception {
-        this.serverBootstrap.registerHandler("*", new BasicRedirectService());
+        this.server.registerHandler("*", new BasicRedirectService());
 
         final HttpHost target = start();
 
@@ -653,7 +685,7 @@ public class TestRedirects extends LocalServerTestBase {
     public void testDefaultHeadersRedirect() throws Exception {
         this.clientBuilder.setDefaultHeaders(Arrays.asList(new BasicHeader(HttpHeaders.USER_AGENT, "my-test-client")));
 
-        this.serverBootstrap.registerHandler("*", new BasicRedirectService());
+        this.server.registerHandler("*", new BasicRedirectService());
 
         final HttpHost target = start();
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSPNegoScheme.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSPNegoScheme.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSPNegoScheme.java
index a9d8a2a..adea0f5 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSPNegoScheme.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSPNegoScheme.java
@@ -149,7 +149,7 @@ public class TestSPNegoScheme extends LocalServerTestBase {
      */
     @Test
     public void testDontTryToAuthenticateEndlessly() throws Exception {
-        this.serverBootstrap.registerHandler("*", new PleaseNegotiateService());
+        this.server.registerHandler("*", new PleaseNegotiateService());
         final HttpHost target = start();
 
         final AuthSchemeProvider nsf = new NegotiateSchemeProviderWithMockGssManager();
@@ -179,7 +179,7 @@ public class TestSPNegoScheme extends LocalServerTestBase {
      */
     @Test
     public void testNoTokenGeneratedError() throws Exception {
-        this.serverBootstrap.registerHandler("*", new PleaseNegotiateService());
+        this.server.registerHandler("*", new PleaseNegotiateService());
         final HttpHost target = start();
 
         final AuthSchemeProvider nsf = new NegotiateSchemeProviderWithMockGssManager();

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java
index 23ef3e9..73a36cc 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java
@@ -75,7 +75,7 @@ public class TestStatefulConnManagement extends LocalServerTestBase {
         final int workerCount = 5;
         final int requestCount = 5;
 
-        this.serverBootstrap.registerHandler("*", new SimpleService());
+        this.server.registerHandler("*", new SimpleService());
 
         this.connManager.setMaxTotal(workerCount);
         this.connManager.setDefaultMaxPerRoute(workerCount);
@@ -194,7 +194,7 @@ public class TestStatefulConnManagement extends LocalServerTestBase {
 
         final int maxConn = 2;
 
-        this.serverBootstrap.registerHandler("*", new SimpleService());
+        this.server.registerHandler("*", new SimpleService());
 
         this.connManager.setMaxTotal(maxConn);
         this.connManager.setDefaultMaxPerRoute(maxConn);
@@ -229,7 +229,7 @@ public class TestStatefulConnManagement extends LocalServerTestBase {
         // Send it to another route. Must be a keepalive.
         final HttpContext context2 = new BasicHttpContext();
         final ClassicHttpResponse response2 = this.httpclient.execute(
-                new HttpHost("127.0.0.1", this.server.getLocalPort()), new HttpGet("/"), context2);
+                new HttpHost("127.0.0.1", this.server.getPort()), new HttpGet("/"), context2);
         EntityUtils.consume(response2.getEntity());
         // ConnPoolByRoute now has 2 free connexions, out of its 2 max.
         // The [localhost][stuff] RouteSpcfcPool is the same as earlier

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestWindowsNegotiateScheme.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestWindowsNegotiateScheme.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestWindowsNegotiateScheme.java
index b7a3502..a1079e5 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestWindowsNegotiateScheme.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestWindowsNegotiateScheme.java
@@ -48,9 +48,7 @@ import org.apache.hc.core5.http.config.RegistryBuilder;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.apache.hc.core5.http.protocol.HttpContext;
-import org.junit.After;
 import org.junit.Assume;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -58,10 +56,9 @@ import org.junit.Test;
  */
 public class TestWindowsNegotiateScheme extends LocalServerTestBase {
 
-    @Before @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        this.serverBootstrap.registerHandler("/", new HttpRequestHandler() {
+    @Test(timeout=30000) // this timeout (in ms) needs to be extended if you're actively debugging the code
+    public void testNoInfiniteLoopOnSPNOutsideDomain() throws Exception {
+        this.server.registerHandler("/", new HttpRequestHandler() {
 
             @Override
             public void handle(
@@ -73,15 +70,6 @@ public class TestWindowsNegotiateScheme extends LocalServerTestBase {
             }
 
         });
-    }
-
-    @After @Override
-    public void shutDown() throws Exception {
-        super.shutDown();
-    }
-
-    @Test(timeout=30000) // this timeout (in ms) needs to be extended if you're actively debugging the code
-    public void testNoInfiniteLoopOnSPNOutsideDomain() throws Exception {
         Assume.assumeTrue("Test can only be run on Windows", WinHttpClients.isWinAuthAvailable());
 
         // HTTPCLIENT-1545

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/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 6566afd..ca7bd01 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
@@ -40,6 +40,7 @@ import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * Example demonstrating how to evict expired and idle connections
@@ -50,7 +51,7 @@ public class AsyncClientConnectionEviction {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/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 a8bc323..efcb975 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
@@ -42,7 +42,7 @@ import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates pipelined execution of multiple HTTP/1.1 message exchanges.
@@ -52,7 +52,7 @@ public class AsyncClientHttp1Pipelining {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(H1Config.DEFAULT, ioReactorConfig);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/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 370d745..ae0c239 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
@@ -42,7 +42,7 @@ import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates concurrent (multiplexed) execution of multiple
@@ -53,7 +53,7 @@ public class AsyncClientHttp2Multiplexing {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(H2Config.DEFAULT, ioReactorConfig);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
index 9d5ee4b..e7d7b42 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
@@ -48,7 +48,7 @@ import org.apache.hc.core5.http2.HttpVersionPolicy;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates handling of HTTP/2 message exchanges pushed by the server.
@@ -58,7 +58,7 @@ public class AsyncClientHttp2ServerPush {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final H2Config h2Config = H2Config.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
index ebe6ff0..000737d 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
@@ -36,7 +36,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * Example of asynchronous HTTP/1.1 request execution.
@@ -46,7 +46,7 @@ public class AsyncClientHttpExchange {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
index 0c5ccca..8f531be 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
@@ -41,7 +41,7 @@ import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.message.StatusLine;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * Example of asynchronous HTTP/1.1 request execution with response streaming.
@@ -51,7 +51,7 @@ public class AsyncClientHttpExchangeStreaming {
     public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
index f591ae4..97297f2 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
@@ -57,7 +57,7 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates how to insert custom request interceptor and an execution interceptor
@@ -68,7 +68,7 @@ public class AsyncClientInterceptors {
     public final static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
index 8445b56..5b42d08 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
@@ -49,7 +49,7 @@ import org.apache.hc.core5.http.nio.entity.DigestingEntityProducer;
 import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates how to use a custom execution interceptor
@@ -60,7 +60,7 @@ public class AsyncClientMessageTrailers {
     public final static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
-                .setSoTimeout(TimeValue.ofSeconds(5))
+                .setSoTimeout(Timeout.ofSeconds(5))
                 .build();
 
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
index cad7f3a..5fa54a9 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
@@ -81,6 +81,7 @@ import org.apache.hc.core5.http.message.LineParser;
 import org.apache.hc.core5.ssl.SSLContexts;
 import org.apache.hc.core5.util.CharArrayBuffer;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * This example demonstrates how to customize and configure the most common aspects
@@ -208,9 +209,9 @@ public class ClientConfiguration {
             // Request configuration can be overridden at the request level.
             // They will take precedence over the one set at the client level.
             final RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig)
-                    .setSocketTimeout(TimeValue.ofSeconds(5))
-                    .setConnectTimeout(TimeValue.ofSeconds(5))
-                    .setConnectionRequestTimeout(TimeValue.ofSeconds(5))
+                    .setSocketTimeout(Timeout.ofSeconds(5))
+                    .setConnectTimeout(Timeout.ofSeconds(5))
+                    .setConnectionRequestTimeout(Timeout.ofSeconds(5))
                     .setProxy(new HttpHost("myotherproxy", 8080))
                     .build();
             httpget.setConfig(requestConfig);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
index 541c55e..716af85 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
@@ -43,7 +43,7 @@ import org.apache.hc.client5.http.sync.methods.HttpGet;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 
 public class ClientWithRequestFuture {
 
@@ -59,8 +59,8 @@ public class ClientWithRequestFuture {
         final ExecutorService execService = Executors.newFixedThreadPool(5);
         try (FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
                 httpclient, execService)) {
-            // Because things are asynchronous, you must provide a ResponseHandler
-            final ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
+            // Because things are asynchronous, you must provide a HttpClientResponseHandler
+            final HttpClientResponseHandler<Boolean> handler = new HttpClientResponseHandler<Boolean>() {
                 @Override
                 public Boolean handleResponse(final ClassicHttpResponse response) throws IOException {
                     // simply return true if the status was OK

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
index f9166d2..38b9aa9 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
+++ b/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
@@ -37,11 +37,11 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 
 /**
- * This example demonstrates the use of the {@link ResponseHandler} to simplify
+ * This example demonstrates the use of the {@link HttpClientResponseHandler} to simplify
  * the process of processing the HTTP response and releasing associated resources.
  */
 public class ClientWithResponseHandler {
@@ -53,7 +53,7 @@ public class ClientWithResponseHandler {
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
 
             // Create a custom response handler
-            final ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
+            final HttpClientResponseHandler<String> responseHandler = new HttpClientResponseHandler<String>() {
 
                 @Override
                 public String handleResponse(

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java b/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
index bd2958c..80f3458 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  *  Immutable class encapsulating request configuration items.
@@ -42,9 +42,9 @@ import org.apache.hc.core5.util.TimeValue;
 @Contract(threading = ThreadingBehavior.IMMUTABLE)
 public class RequestConfig implements Cloneable {
 
-    private static final TimeValue DEFAULT_CONNECTION_REQUEST_TIMEOUT = TimeValue.ofMinutes(3);
-    private static final TimeValue DEFAULT_CONNECT_TIMEOUT = TimeValue.ofMinutes(3);
-    private static final TimeValue DEFAULT_SOCKET_TIMEOUT = TimeValue.NEG_ONE_MILLISECONDS;
+    private static final Timeout DEFAULT_CONNECTION_REQUEST_TIMEOUT = Timeout.ofMinutes(3);
+    private static final Timeout DEFAULT_CONNECT_TIMEOUT = Timeout.ofMinutes(3);
+    private static final Timeout DEFAULT_SOCKET_TIMEOUT = Timeout.ZERO_MILLISECONDS;
 
     public static final RequestConfig DEFAULT = new Builder().build();
 
@@ -58,9 +58,9 @@ public class RequestConfig implements Cloneable {
     private final boolean authenticationEnabled;
     private final Collection<String> targetPreferredAuthSchemes;
     private final Collection<String> proxyPreferredAuthSchemes;
-    private final TimeValue connectionRequestTimeout;
-    private final TimeValue connectTimeout;
-    private final TimeValue socketTimeout;
+    private final Timeout connectionRequestTimeout;
+    private final Timeout connectTimeout;
+    private final Timeout socketTimeout;
     private final boolean contentCompressionEnabled;
 
     /**
@@ -82,9 +82,9 @@ public class RequestConfig implements Cloneable {
             final boolean authenticationEnabled,
             final Collection<String> targetPreferredAuthSchemes,
             final Collection<String> proxyPreferredAuthSchemes,
-            final TimeValue connectionRequestTimeout,
-            final TimeValue connectTimeout,
-            final TimeValue socketTimeout,
+            final Timeout connectionRequestTimeout,
+            final Timeout connectTimeout,
+            final Timeout socketTimeout,
             final boolean contentCompressionEnabled) {
         super();
         this.expectContinueEnabled = expectContinueEnabled;
@@ -242,7 +242,7 @@ public class RequestConfig implements Cloneable {
      * Default: 3 minutes.
      * </p>
      */
-    public TimeValue getConnectionRequestTimeout() {
+    public Timeout getConnectionRequestTimeout() {
         return connectionRequestTimeout;
     }
 
@@ -257,7 +257,7 @@ public class RequestConfig implements Cloneable {
      * Default: 3 minutes
      * </p>
      */
-    public TimeValue getConnectTimeout() {
+    public Timeout getConnectTimeout() {
         return connectTimeout;
     }
 
@@ -273,7 +273,7 @@ public class RequestConfig implements Cloneable {
      * Default: no timeout.
      * </p>
      */
-    public TimeValue getSocketTimeout() {
+    public Timeout getSocketTimeout() {
         return socketTimeout;
     }
 
@@ -350,9 +350,9 @@ public class RequestConfig implements Cloneable {
         private boolean authenticationEnabled;
         private Collection<String> targetPreferredAuthSchemes;
         private Collection<String> proxyPreferredAuthSchemes;
-        private TimeValue connectionRequestTimeout;
-        private TimeValue connectTimeout;
-        private TimeValue socketTimeout;
+        private Timeout connectionRequestTimeout;
+        private Timeout connectTimeout;
+        private Timeout socketTimeout;
         private boolean contentCompressionEnabled;
 
         Builder() {
@@ -416,33 +416,33 @@ public class RequestConfig implements Cloneable {
             return this;
         }
 
-        public Builder setConnectionRequestTimeout(final TimeValue connectionRequestTimeout) {
+        public Builder setConnectionRequestTimeout(final Timeout connectionRequestTimeout) {
             this.connectionRequestTimeout = connectionRequestTimeout;
             return this;
         }
 
         public Builder setConnectionRequestTimeout(final long connectionRequestTimeout, final TimeUnit timeUnit) {
-            this.connectionRequestTimeout = TimeValue.of(connectionRequestTimeout, timeUnit);
+            this.connectionRequestTimeout = Timeout.of(connectionRequestTimeout, timeUnit);
             return this;
         }
 
-        public Builder setConnectTimeout(final TimeValue connectTimeout) {
+        public Builder setConnectTimeout(final Timeout connectTimeout) {
             this.connectTimeout = connectTimeout;
             return this;
         }
 
         public Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeUnit) {
-            this.connectTimeout = TimeValue.of(connectTimeout, timeUnit);
+            this.connectTimeout = Timeout.of(connectTimeout, timeUnit);
             return this;
         }
 
-        public Builder setSocketTimeout(final TimeValue socketTimeout) {
+        public Builder setSocketTimeout(final Timeout socketTimeout) {
             this.socketTimeout = socketTimeout;
             return this;
         }
 
         public Builder setSocketTimeout(final long socketTimeout, final TimeUnit timeUnit) {
-            this.socketTimeout = TimeValue.of(socketTimeout, timeUnit);
+            this.socketTimeout = Timeout.of(socketTimeout, timeUnit);
             return this;
         }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NamedElementChain.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NamedElementChain.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NamedElementChain.java
deleted file mode 100644
index 11cf854..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NamedElementChain.java
+++ /dev/null
@@ -1,212 +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.impl;
-
-import org.apache.hc.core5.util.Args;
-
-/**
- * Chain of doubly linked elements.
- * <p>
- * This implementation makes no attempts to ensure uniqueness of element names.
- *
- * @param <E>
- */
-public class NamedElementChain<E> {
-
-    private final Node master;
-    private int size;
-
-    public NamedElementChain() {
-        this.master = new Node("master", null);
-        this.master.previous = this.master;
-        this.master.next = this.master;
-        this.size = 0;
-    }
-
-    public Node getFirst() {
-        if (master.next != master) {
-            return master.next;
-        } else {
-            return null;
-        }
-    }
-
-    public Node getLast() {
-        if (master.previous != master) {
-            return master.previous;
-        } else {
-            return null;
-        }
-    }
-
-    public Node addFirst(final E value, final String name) {
-        Args.notBlank(name, "Name");
-        Args.notNull(value, "Value");
-        final Node newNode = new Node(name, value);
-        final Node oldNode = master.next;
-        master.next = newNode;
-        newNode.previous = master;
-        newNode.next = oldNode;
-        oldNode.previous = newNode;
-        size++;
-        return newNode;
-    }
-
-    public Node addLast(final E value, final String name) {
-        Args.notBlank(name, "Name");
-        Args.notNull(value, "Value");
-        final Node newNode = new Node(name, value);
-        final Node oldNode = master.previous;
-        master.previous = newNode;
-        newNode.previous = oldNode;
-        newNode.next = master;
-        oldNode.next = newNode;
-        size++;
-        return newNode;
-    }
-
-    public Node find(final String name) {
-        Args.notBlank(name, "Name");
-        return doFind(name);
-    }
-
-    private Node doFind(final String name) {
-        Node current = master.next;
-        while (current != master) {
-            if (name.equals(current.name)) {
-                return current;
-            }
-            current = current.next;
-        }
-        return null;
-    }
-
-    public Node addBefore(final String existing, final E value, final String name) {
-        Args.notBlank(name, "Name");
-        Args.notNull(value, "Value");
-        final Node current = doFind(existing);
-        if (current == null) {
-            return null;
-        }
-        final Node newNode = new Node(name, value);
-        final Node previousNode = current.previous;
-        previousNode.next = newNode;
-        newNode.previous = previousNode;
-        newNode.next = current;
-        current.previous = newNode;
-        size++;
-        return newNode;
-    }
-
-    public Node addAfter(final String existing, final E value, final String name) {
-        Args.notBlank(name, "Name");
-        Args.notNull(value, "Value");
-        final Node current = doFind(existing);
-        if (current == null) {
-            return null;
-        }
-        final Node newNode = new Node(name, value);
-        final Node nextNode = current.next;
-        current.next = newNode;
-        newNode.previous = current;
-        newNode.next = nextNode;
-        nextNode.previous = newNode;
-        size++;
-        return newNode;
-    }
-
-    public boolean remove(final String name) {
-        final Node node = doFind(name);
-        if (node == null) {
-            return false;
-        }
-        node.previous.next = node.next;
-        node.next.previous = node.previous;
-        node.previous = null;
-        node.next = null;
-        size--;
-        return true;
-    }
-
-    public boolean replace(final String existing, final E value) {
-        final Node node = doFind(existing);
-        if (node == null) {
-            return false;
-        }
-        node.value = value;
-        return true;
-    }
-
-    public int getSize() {
-        return size;
-    }
-
-    public class Node {
-
-        private final String name;
-        private E value;
-        private Node previous;
-        private Node next;
-
-        Node(final String name, final E value) {
-            this.name = name;
-            this.value = value;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public E getValue() {
-            return value;
-        }
-
-        public Node getPrevious() {
-            if (previous != master) {
-                return previous;
-            } else {
-                return null;
-            }
-        }
-
-        public Node getNext() {
-            if (next != master) {
-                return next;
-            } else {
-                return null;
-            }
-        }
-
-        @Override
-        public String toString() {
-            return name + ": " + value;
-        }
-
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
index bcfb00c..11ccf4a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
@@ -33,7 +33,6 @@ import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.hc.core5.function.Supplier;
-import org.apache.hc.core5.http.ExceptionListener;
 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
@@ -52,7 +51,6 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient {
 
     private final AsyncPushConsumerRegistry pushConsumerRegistry;
     private final DefaultConnectingIOReactor ioReactor;
-    private final ExceptionListener exceptionListener;
     private final ExecutorService executorService;
     private final AtomicReference<Status> status;
 
@@ -63,14 +61,6 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient {
         super();
         this.ioReactor = ioReactor;
         this.pushConsumerRegistry = pushConsumerRegistry;
-        this.exceptionListener = new ExceptionListener() {
-
-            @Override
-            public void onError(final Exception ex) {
-                log.error(ex.getMessage(), ex);
-            }
-
-        };
         this.executorService = Executors.newSingleThreadExecutor(threadFactory);
         this.status = new AtomicReference<>(Status.READY);
     }
@@ -82,11 +72,7 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient {
 
                 @Override
                 public void run() {
-                    try {
-                        ioReactor.execute();
-                    } catch (final Exception ex) {
-                        exceptionListener.onError(ex);
-                    }
+                    ioReactor.start();
                 }
             });
         }
@@ -116,8 +102,8 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient {
     }
 
     @Override
-    public final List<ExceptionEvent> getAuditLog() {
-        return ioReactor.getAuditLog();
+    public final List<ExceptionEvent> getExceptionLog() {
+        return ioReactor.getExceptionLog();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/BasicAsyncEntityProducer.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/BasicAsyncEntityProducer.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/BasicAsyncEntityProducer.java
deleted file mode 100644
index 7c804b4..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/BasicAsyncEntityProducer.java
+++ /dev/null
@@ -1,94 +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.impl.async;
-
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.hc.core5.http.EntityDetails;
-import org.apache.hc.core5.http.nio.AsyncDataProducer;
-import org.apache.hc.core5.http.nio.AsyncEntityProducer;
-import org.apache.hc.core5.http.nio.DataStreamChannel;
-import org.apache.hc.core5.util.Args;
-
-public class BasicAsyncEntityProducer implements AsyncEntityProducer {
-
-    private final AsyncDataProducer dataProducer;
-    private final EntityDetails entityDetails;
-
-    BasicAsyncEntityProducer(final AsyncDataProducer dataProducer, final EntityDetails entityDetails) {
-        this.dataProducer = Args.notNull(dataProducer, "Data producer");
-        this.entityDetails = Args.notNull(entityDetails, "Entity details");
-    }
-
-    @Override
-    public void releaseResources() {
-        dataProducer.releaseResources();
-    }
-
-    @Override
-    public void failed(final Exception cause) {
-        dataProducer.releaseResources();
-    }
-
-    @Override
-    public long getContentLength() {
-        return entityDetails.getContentLength();
-    }
-
-    @Override
-    public String getContentType() {
-        return entityDetails.getContentType();
-    }
-
-    @Override
-    public String getContentEncoding() {
-        return entityDetails.getContentEncoding();
-    }
-
-    @Override
-    public boolean isChunked() {
-        return entityDetails.isChunked();
-    }
-
-    @Override
-    public Set<String> getTrailerNames() {
-        return entityDetails.getTrailerNames();
-    }
-
-    @Override
-    public int available() {
-        return dataProducer.available();
-    }
-
-    @Override
-    public void produce(final DataStreamChannel channel) throws IOException {
-        dataProducer.produce(channel);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/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 392ac6b..5526800 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
@@ -62,7 +62,7 @@ public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Close
 
     public abstract IOReactorStatus getStatus();
 
-    public abstract List<ExceptionEvent> getAuditLog();
+    public abstract List<ExceptionEvent> getExceptionLog();
 
     public abstract void awaitShutdown(TimeValue waitTime) throws InterruptedException;
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
index 6884849..61b6abb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
@@ -53,7 +53,6 @@ import org.apache.hc.client5.http.impl.DefaultConnectionKeepAliveStrategy;
 import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
 import org.apache.hc.client5.http.impl.DefaultUserTokenHandler;
 import org.apache.hc.client5.http.impl.IdleConnectionEvictor;
-import org.apache.hc.client5.http.impl.NamedElementChain;
 import org.apache.hc.client5.http.impl.NoopUserTokenHandler;
 import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
 import org.apache.hc.client5.http.impl.auth.CredSspSchemeFactory;
@@ -97,6 +96,7 @@ import org.apache.hc.core5.http.HttpResponseInterceptor;
 import org.apache.hc.core5.http.config.CharCodingConfig;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.NamedElementChain;
 import org.apache.hc.core5.http.config.RegistryBuilder;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
@@ -118,7 +118,6 @@ import org.apache.hc.core5.pool.ConnPoolControl;
 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.reactor.IOReactorException;
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.TimeValue;
@@ -904,7 +903,7 @@ public class HttpAsyncClientBuilder {
                 new HandlerFactory<AsyncPushConsumer>() {
 
                     @Override
-                    public AsyncPushConsumer create(final HttpRequest request) throws HttpException {
+                    public AsyncPushConsumer create(final HttpRequest request, final HttpContext context) throws HttpException {
                         return pushConsumerRegistry.get(request);
                     }
 
@@ -914,23 +913,20 @@ public class HttpAsyncClientBuilder {
                 h1Config != null ? h1Config : H1Config.DEFAULT,
                 charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
                 reuseStrategyCopy);
-        final DefaultConnectingIOReactor ioReactor;
-        try {
-            ioReactor = new DefaultConnectingIOReactor(
-                    ioEventHandlerFactory,
-                    ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
-                    threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
-                    new Callback<IOSession>() {
+        final DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(
+                ioEventHandlerFactory,
+                ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
+                threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
+                null,
+                null,
+                new Callback<IOSession>() {
 
-                        @Override
-                        public void execute(final IOSession ioSession) {
-                            ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
-                        }
+                    @Override
+                    public void execute(final IOSession ioSession) {
+                        ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
+                    }
 
-                    });
-        } catch (final IOReactorException ex) {
-            throw new IllegalStateException(ex.getMessage(), ex);
-        }
+                });
 
         if (execInterceptors != null) {
             for (final ExecInterceptorEntry entry: execInterceptors) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
index 24a1c37..1419b44 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
@@ -36,7 +36,6 @@ import org.apache.hc.client5.http.impl.logging.LogAppendable;
 import org.apache.hc.client5.http.impl.logging.LoggingIOSession;
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.ConnectionReuseStrategy;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpConnection;
@@ -44,7 +43,6 @@ import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.config.CharCodingConfig;
 import org.apache.hc.core5.http.config.H1Config;
-import org.apache.hc.core5.http.impl.ConnectionListener;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.hc.core5.http.impl.Http1StreamListener;
 import org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexerFactory;
@@ -124,31 +122,6 @@ public class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory
                 || framePayloadLog.isDebugEnabled()
                 || flowCtrlLog.isDebugEnabled()) {
             final String id = ConnPoolSupport.getId(ioSession);
-            final ConnectionListener connectionListener = new ConnectionListener() {
-
-                @Override
-                public void onConnect(final HttpConnection connection) {
-                    if (streamLog.isDebugEnabled()) {
-                        streamLog.debug(id + ": " + connection + " connected");
-                    }
-                }
-
-                @Override
-                public void onDisconnect(final HttpConnection connection) {
-                    if (streamLog.isDebugEnabled()) {
-                        streamLog.debug(id + ": " + connection + " disconnected");
-                    }
-                }
-
-                @Override
-                public void onError(final HttpConnection connection, final Exception ex) {
-                    if (ex instanceof ConnectionClosedException) {
-                        return;
-                    }
-                    streamLog.error(id + ": " + ex.getMessage(), ex);
-                }
-
-            };
             final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
                     httpProcessor,
                     h1Config,
@@ -156,7 +129,6 @@ public class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory
                     http1ConnectionReuseStrategy,
                     http1ResponseParserFactory,
                     http1RequestWriterFactory,
-                    connectionListener,
                     new Http1StreamListener() {
 
                         @Override
@@ -196,7 +168,6 @@ public class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory
                     exchangeHandlerFactory,
                     h2Config,
                     charCodingConfig,
-                    connectionListener,
                     new Http2StreamListener() {
 
                         final FramePrinter framePrinter = new FramePrinter();
@@ -285,8 +256,7 @@ public class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory
                             loggingIOSession,
                             http1StreamHandlerFactory,
                             http2StreamHandlerFactory,
-                            attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy,
-                            connectionListener);
+                            attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy);
         } else {
             final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
                     httpProcessor,
@@ -295,19 +265,18 @@ public class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory
                     http1ConnectionReuseStrategy,
                     http1ResponseParserFactory,
                     http1RequestWriterFactory,
-                    null, null);
+                    null);
             final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
                     httpProcessor,
                     exchangeHandlerFactory,
                     h2Config,
                     charCodingConfig,
-                    null, null);
+                    null);
             return new ClientHttpProtocolNegotiator(
                     ioSession,
                     http1StreamHandlerFactory,
                     http2StreamHandlerFactory,
-                    attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy,
-                    null);
+                    attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy);
         }
    }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java
index c023632..e610029 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java
@@ -43,7 +43,6 @@ import org.apache.hc.core5.http2.protocol.H2RequestContent;
 import org.apache.hc.core5.http2.protocol.H2RequestTargetHost;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.reactor.IOReactorException;
 import org.apache.hc.core5.util.VersionInfo;
 
 /**
@@ -95,18 +94,14 @@ public class HttpAsyncClients {
             final HttpVersionPolicy versionPolicy,
             final IOReactorConfig ioReactorConfig,
             final AsyncClientConnectionManager connmgr) {
-        try {
-            return new MinimalHttpAsyncClient(
-                    eventHandlerFactory,
-                    pushConsumerRegistry,
-                    versionPolicy,
-                    ioReactorConfig,
-                    new DefaultThreadFactory("httpclient-main", true),
-                    new DefaultThreadFactory("httpclient-dispatch", true),
-                    connmgr);
-        } catch (final IOReactorException ex) {
-            throw new IllegalStateException(ex.getMessage(), ex);
-        }
+        return new MinimalHttpAsyncClient(
+                eventHandlerFactory,
+                pushConsumerRegistry,
+                versionPolicy,
+                ioReactorConfig,
+                new DefaultThreadFactory("httpclient-main", true),
+                new DefaultThreadFactory("httpclient-dispatch", true),
+                connmgr);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalAsyncEntityProducer.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalAsyncEntityProducer.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalAsyncEntityProducer.java
new file mode 100644
index 0000000..14840e5
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalAsyncEntityProducer.java
@@ -0,0 +1,93 @@
+/*
+ * ====================================================================
+ * 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.impl.async;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.nio.AsyncDataProducer;
+import org.apache.hc.core5.http.nio.AsyncEntityProducer;
+import org.apache.hc.core5.http.nio.DataStreamChannel;
+
+final class InternalAsyncEntityProducer implements AsyncEntityProducer {
+
+    private final AsyncDataProducer dataProducer;
+    private final EntityDetails entityDetails;
+
+    InternalAsyncEntityProducer(final AsyncDataProducer dataProducer, final EntityDetails entityDetails) {
+        this.dataProducer = dataProducer;
+        this.entityDetails = entityDetails;
+    }
+
+    @Override
+    public void releaseResources() {
+        dataProducer.releaseResources();
+    }
+
+    @Override
+    public void failed(final Exception cause) {
+        dataProducer.releaseResources();
+    }
+
+    @Override
+    public long getContentLength() {
+        return entityDetails.getContentLength();
+    }
+
+    @Override
+    public String getContentType() {
+        return entityDetails.getContentType();
+    }
+
+    @Override
+    public String getContentEncoding() {
+        return entityDetails.getContentEncoding();
+    }
+
+    @Override
+    public boolean isChunked() {
+        return entityDetails.isChunked();
+    }
+
+    @Override
+    public Set<String> getTrailerNames() {
+        return entityDetails.getTrailerNames();
+    }
+
+    @Override
+    public int available() {
+        return dataProducer.available();
+    }
+
+    @Override
+    public void produce(final DataStreamChannel channel) throws IOException {
+        dataProducer.produce(channel);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/b58e7d46/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 013e687..d001458 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
@@ -53,6 +53,8 @@ import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.config.Lookup;
 import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
 import org.apache.hc.core5.http.nio.AsyncDataConsumer;
@@ -150,9 +152,9 @@ class InternalHttpAsyncClient extends AbstractHttpAsyncClientBase {
             log.debug(exchangeId + ": preparing request execution");
         }
 
-        //TODO remove when fixed in HttpCore
-        if (route.isTunnelled()) {
-            throw new HttpException("HTTP tunneling not supported");
+        final ProtocolVersion protocolVersion = clientContext.getProtocolVersion();
+        if (route.isTunnelled() && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
+            throw new HttpException("HTTP/2 tunneling not supported");
         }
 
         setupContext(clientContext);
@@ -160,7 +162,7 @@ class InternalHttpAsyncClient extends AbstractHttpAsyncClientBase {
         final AsyncExecChain.Scope scope = new AsyncExecChain.Scope(exchangeId, route, request, clientContext, execRuntime);
         execChain.execute(
                 ExecSupport.copy(request),
-                entityDetails != null ? new BasicAsyncEntityProducer(exchangeHandler, entityDetails) : null,
+                entityDetails != null ? new InternalAsyncEntityProducer(exchangeHandler, entityDetails) : null,
                 scope,
                 new AsyncExecCallback() {
 


Mime
View raw message