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 2016/11/13 14:06:33 UTC

svn commit: r1769496 [1/2] - in /httpcomponents/httpcore/trunk: ./ httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ httpcore5-testing/src/main/java/org/apache/hc/core5/testing/n...

Author: olegk
Date: Sun Nov 13 14:06:33 2016
New Revision: 1769496

URL: http://svn.apache.org/viewvc?rev=1769496&view=rev
Log:
Redesign of non-blocking SSL/TLS APIs

Added:
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ProtocolScheme.java
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2-debug.xml.template
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/test.keystore
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/NamedEndpoint.java
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java   (contents, props changed)
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/ReleasableSSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLSessionInitializer.java
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLSessionVerifier.java   (contents, props changed)
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLSetupHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java   (contents, props changed)
      - copied, changed from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java
Removed:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/PermanentSSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/ReleasableSSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLSetupHandler.java
Modified:
    httpcomponents/httpcore/trunk/.gitignore
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalHttp2StreamListener.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncRequester.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncServer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/pool/BasicNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/AbstractNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionInitiator.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultConnectingIOReactor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/SessionRequest.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/SessionRequestImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/pool/nio/TestNIOConnPool.java

Modified: httpcomponents/httpcore/trunk/.gitignore
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/.gitignore?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/.gitignore (original)
+++ httpcomponents/httpcore/trunk/.gitignore Sun Nov 13 14:06:33 2016
@@ -7,3 +7,4 @@ target
 maven-eclipse.xml
 .idea
 *.iml
+/httpcore5-testing/src/test/resources/log4j2-debug.xml

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java Sun Nov 13 14:06:33 2016
@@ -44,8 +44,6 @@ import org.apache.hc.core5.http.impl.nio
 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
 import org.apache.hc.core5.http.nio.HandlerFactory;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
-import org.apache.hc.core5.http2.H2ConnectionException;
-import org.apache.hc.core5.http2.H2Error;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.http2.frame.DefaultFrameFactory;
 import org.apache.hc.core5.reactor.IOEventHandler;
@@ -71,6 +69,7 @@ public class ClientHttpProtocolNegotiato
     private final HandlerFactory<AsyncPushConsumer> pushHandlerFactory;
     private final ConnectionListener connectionListener;
     private final Http2StreamListener streamListener;
+    private final ByteBuffer preface;
 
     public ClientHttpProtocolNegotiator(
             final IOSession ioSession,
@@ -87,6 +86,7 @@ public class ClientHttpProtocolNegotiato
         this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
         this.streamListener = streamListener;
         this.connectionListener = connectionListener;
+        this.preface = ByteBuffer.wrap(PREFACE);
     }
 
     protected ClientHttp2StreamMultiplexer createStreamMultiplexer(final IOSession ioSession) {
@@ -96,24 +96,7 @@ public class ClientHttpProtocolNegotiato
 
     @Override
     public void connected(final IOSession ioSession) {
-        try {
-            final ByteChannel channel = ioSession.channel();
-            final ByteBuffer preface = ByteBuffer.wrap(PREFACE);
-            final int bytesWritten = channel.write(preface);
-            if (bytesWritten != PREFACE.length) {
-                throw new H2ConnectionException(H2Error.INTERNAL_ERROR, "HTTP/2 preface failed");
-            }
-        } catch (IOException ex) {
-            ioSession.shutdown();
-            if (connectionListener != null) {
-                connectionListener.onError(this, ex);
-            }
-            return;
-        }
-        final ClientHttp2StreamMultiplexer streamMultiplexer = createStreamMultiplexer(ioSession);
-        final IOEventHandler newHandler = new ClientHttp2IOEventHandler(streamMultiplexer);
-        newHandler.connected(ioSession);
-        ioSession.setHandler(newHandler);
+        outputReady(ioSession);
     }
 
     @Override
@@ -122,6 +105,24 @@ public class ClientHttpProtocolNegotiato
 
     @Override
     public void outputReady(final IOSession session) {
+        if (preface.hasRemaining()) {
+            try {
+                final ByteChannel channel = ioSession.channel();
+                channel.write(preface);
+            } catch (IOException ex) {
+                ioSession.shutdown();
+                if (connectionListener != null) {
+                    connectionListener.onError(this, ex);
+                }
+                return;
+            }
+        }
+        if (!preface.hasRemaining()) {
+            final ClientHttp2StreamMultiplexer streamMultiplexer = createStreamMultiplexer(ioSession);
+            final IOEventHandler newHandler = new ClientHttp2IOEventHandler(streamMultiplexer);
+            newHandler.connected(ioSession);
+            ioSession.setHandler(newHandler);
+        }
     }
 
     @Override

Copied: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ProtocolScheme.java (from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ProtocolScheme.java?p2=httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ProtocolScheme.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java&r1=1769014&r2=1769496&rev=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/ProtocolScheme.java Sun Nov 13 14:06:33 2016
@@ -25,20 +25,6 @@
  *
  */
 
-package org.apache.hc.core5.pool.nio;
+package org.apache.hc.core5.testing;
 
-import java.io.IOException;
-import java.net.SocketAddress;
-
-/**
- * Strategy that resolves an abstract connection route to a local or a remote {@link SocketAddress}.
- *
- * @since 4.3
- */
-public interface SocketAddressResolver<T> {
-
-    SocketAddress resolveLocalAddress(T route) throws IOException;
-
-    SocketAddress resolveRemoteAddress(T route) throws IOException;
-
-}
+public enum ProtocolScheme { HTTP, HTTPS }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java Sun Nov 13 14:06:33 2016
@@ -33,12 +33,18 @@ import java.nio.ByteBuffer;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.SelectionKey;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.reactor.Command;
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
+import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
+import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.testing.classic.Wire;
 import org.apache.logging.log4j.Logger;
-public class LoggingIOSession implements IOSession {
+public class LoggingIOSession implements IOSession, TlsCapable {
 
     private final Logger log;
     private final Wire wirelog;
@@ -187,6 +193,28 @@ public class LoggingIOSession implements
     }
 
     @Override
+    public void startTls(
+            final SSLContext sslContext,
+            final SSLBufferManagement sslBufferManagement,
+            final SSLSessionInitializer initializer,
+            final SSLSessionVerifier verifier) throws UnsupportedOperationException {
+        if (session instanceof TlsCapable) {
+            ((TlsCapable) session).startTls(sslContext, sslBufferManagement, initializer, verifier);
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public boolean isTlsActive() {
+        if (session instanceof TlsCapable) {
+            return ((TlsCapable) session).isTlsActive();
+        } else {
+            return false;
+        }
+    }
+
+    @Override
     public String toString() {
         return this.id + " " + this.session.toString();
     }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java Sun Nov 13 14:06:33 2016
@@ -28,14 +28,16 @@
 package org.apache.hc.core5.testing.nio.http;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ExceptionListener;
+import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.config.ConnectionConfig;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
@@ -46,6 +48,7 @@ import org.apache.hc.core5.http.impl.nio
 import org.apache.hc.core5.http.nio.command.ShutdownCommand;
 import org.apache.hc.core5.http.nio.command.ShutdownType;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.IOSessionCallback;
@@ -55,7 +58,9 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.Logger;
 public class Http1TestClient extends AsyncRequester {
 
-    public Http1TestClient(final IOReactorConfig ioReactorConfig) throws IOException {
+    private final SSLContext sslContext;
+
+    public Http1TestClient(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException {
         super(ioReactorConfig, new ExceptionListener() {
 
             private final Logger log = LogManager.getLogger(Http1TestClient.class);
@@ -71,10 +76,11 @@ public class Http1TestClient extends Asy
                 session.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
             }
         });
+        this.sslContext = sslContext;
     }
 
     public Http1TestClient() throws IOException {
-        this(IOReactorConfig.DEFAULT);
+        this(IOReactorConfig.DEFAULT, null);
     }
 
     public void start(
@@ -85,7 +91,8 @@ public class Http1TestClient extends Asy
                 httpProcessor,
                 h1Config,
                 connectionConfig,
-                DefaultConnectionReuseStrategy.INSTANCE));
+                DefaultConnectionReuseStrategy.INSTANCE,
+                sslContext));
     }
 
     public void start(final H1Config h1Config, final ConnectionConfig connectionConfig) throws IOException {
@@ -102,20 +109,20 @@ public class Http1TestClient extends Asy
 
     @Override
     public SessionRequest requestSession(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit,
             final SessionRequestCallback callback) throws InterruptedException {
-        return super.requestSession(address, timeout, timeUnit, callback);
+        return super.requestSession(remoteEndpoint, timeout, timeUnit, callback);
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit,
             final FutureCallback<ClientEndpoint> callback) throws InterruptedException {
         final BasicFuture<ClientEndpoint> future = new BasicFuture<>(callback);
-        requestSession(address, timeout, timeUnit, new SessionRequestCallback() {
+        requestSession(remoteEndpoint, timeout, timeUnit, new SessionRequestCallback() {
 
             @Override
             public void completed(final SessionRequest request) {
@@ -142,10 +149,10 @@ public class Http1TestClient extends Asy
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit) throws InterruptedException {
-        return connect(address, timeout, timeUnit, null);
+        return connect(remoteEndpoint, timeout, timeUnit, null);
     }
 
     public Future<ClientEndpoint> connect(
@@ -153,7 +160,7 @@ public class Http1TestClient extends Asy
             final int port,
             final long timeout,
             final TimeUnit timeUnit) throws InterruptedException {
-        return connect(new InetSocketAddress(hostname, port), timeout, timeUnit);
+        return connect(new HttpHost(hostname, port), timeout, timeUnit);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.testing.nio.
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.http.ExceptionListener;
 import org.apache.hc.core5.http.config.ConnectionConfig;
 import org.apache.hc.core5.http.config.H1Config;
@@ -55,8 +57,9 @@ import org.apache.logging.log4j.Logger;
 public class Http1TestServer extends AsyncServer {
 
     private final AsyncServerExchangeHandlerRegistry handlerRegistry;
+    private final SSLContext sslContext;
 
-    public Http1TestServer(final IOReactorConfig ioReactorConfig) throws IOException {
+    public Http1TestServer(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException {
         super(ioReactorConfig, new ExceptionListener() {
 
             private final Logger log = LogManager.getLogger(Http1TestServer.class);
@@ -75,10 +78,11 @@ public class Http1TestServer extends Asy
 
         });
         this.handlerRegistry = new AsyncServerExchangeHandlerRegistry("localhost");
+        this.sslContext = sslContext;
     }
 
     public Http1TestServer() throws IOException {
-        this(IOReactorConfig.DEFAULT);
+        this(IOReactorConfig.DEFAULT, null);
     }
 
     public void register(final String uriPattern, final Supplier<AsyncServerExchangeHandler> supplier) {
@@ -112,7 +116,8 @@ public class Http1TestServer extends Asy
                 handlerRegistry,
                 h1Config,
                 ConnectionConfig.DEFAULT,
-                DefaultConnectionReuseStrategy.INSTANCE));
+                DefaultConnectionReuseStrategy.INSTANCE,
+                sslContext));
     }
 
     public InetSocketAddress start() throws Exception {

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.testing.nio.
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.ConnectionClosedException;
@@ -58,6 +60,7 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
 import org.apache.hc.core5.testing.nio.LoggingIOSession;
 import org.apache.hc.core5.util.Args;
@@ -76,17 +79,20 @@ class InternalClientHttp1EventHandlerFac
     private final H1Config h1Config;
     private final ConnectionConfig connectionConfig;
     private final ConnectionReuseStrategy connectionReuseStrategy;
+    private final SSLContext sslContext;
 
     InternalClientHttp1EventHandlerFactory(
             final HttpProcessor httpProcessor,
             final H1Config h1Config,
             final ConnectionConfig connectionConfig,
-            final ConnectionReuseStrategy connectionReuseStrategy) {
+            final ConnectionReuseStrategy connectionReuseStrategy,
+            final SSLContext sslContext) {
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.connectionConfig = connectionConfig != null ? connectionConfig: ConnectionConfig.DEFAULT;
         this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
                 DefaultConnectionReuseStrategy.INSTANCE;
+        this.sslContext = sslContext;
     }
 
     protected ClientHttp1StreamDuplexer createClientHttp1StreamDuplexer(
@@ -110,6 +116,9 @@ class InternalClientHttp1EventHandlerFac
     @Override
     public IOEventHandler createHandler(final IOSession ioSession) {
         final String id = "http1-outgoing-" + COUNT.incrementAndGet();
+        if (sslContext != null && ioSession instanceof TlsCapable) {
+            ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+        }
         final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
         final Logger wireLog = LogManager.getLogger("org.apache.hc.core5.http.wire");
         final Logger headerLog = LogManager.getLogger("org.apache.hc.core5.http.headers");
@@ -185,7 +194,6 @@ class InternalClientHttp1EventHandlerFac
                     }
 
                 });
-
         return new LoggingIOEventHandler(new ClientHttp1IOEventHandler(streamDuplexer), id, sessionLog);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.testing.nio.
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.ConnectionClosedException;
@@ -60,6 +62,7 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
 import org.apache.hc.core5.testing.nio.LoggingIOSession;
 import org.apache.hc.core5.util.Args;
@@ -78,19 +81,22 @@ class InternalServerHttp1EventHandlerFac
     private final H1Config h1Config;
     private final ConnectionConfig connectionConfig;
     private final ConnectionReuseStrategy connectionReuseStrategy;
+    private final SSLContext sslContext;
 
     InternalServerHttp1EventHandlerFactory(
             final HttpProcessor httpProcessor,
             final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
             final H1Config h1Config,
             final ConnectionConfig connectionConfig,
-            final ConnectionReuseStrategy connectionReuseStrategy) {
+            final ConnectionReuseStrategy connectionReuseStrategy,
+            final SSLContext sslContext) {
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
         this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.connectionConfig = connectionConfig != null ? connectionConfig: ConnectionConfig.DEFAULT;
         this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
                 DefaultConnectionReuseStrategy.INSTANCE;
+        this.sslContext = sslContext;
     }
 
     protected ServerHttp1StreamDuplexer createServerHttp1StreamDuplexer(
@@ -114,6 +120,9 @@ class InternalServerHttp1EventHandlerFac
     @Override
     public IOEventHandler createHandler(final IOSession ioSession) {
         final String id = "http1-incoming-" + COUNT.incrementAndGet();
+        if (sslContext != null && ioSession instanceof TlsCapable) {
+            ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+        }
         final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
         final Logger wireLog = LogManager.getLogger("org.apache.hc.core5.http.wire");
         final Logger headerLog = LogManager.getLogger("org.apache.hc.core5.http.headers");
@@ -191,7 +200,6 @@ class InternalServerHttp1EventHandlerFac
                     }
 
                 });
-
         return new LoggingIOEventHandler(new ServerHttp1IOEventHandler(streamDuplexer), id, sessionLog);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java Sun Nov 13 14:06:33 2016
@@ -28,12 +28,13 @@
 package org.apache.hc.core5.testing.nio.http2;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.nio.charset.StandardCharsets;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ExceptionListener;
@@ -54,6 +55,7 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.http.protocol.UriPatternMatcher;
 import org.apache.hc.core5.http2.bootstrap.Http2Processors;
 import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.IOSession;
@@ -65,9 +67,10 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.Logger;
 public class Http2TestClient extends AsyncRequester {
 
+    private final SSLContext sslContext;
     private final UriPatternMatcher<Supplier<AsyncPushConsumer>> pushHandlerMatcher;
 
-    public Http2TestClient(final IOReactorConfig ioReactorConfig) throws IOException {
+    public Http2TestClient(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException {
         super(ioReactorConfig, new ExceptionListener() {
 
             private final Logger log = LogManager.getLogger(Http2TestClient.class);
@@ -85,11 +88,12 @@ public class Http2TestClient extends Asy
             }
 
         });
+        this.sslContext = sslContext;
         this.pushHandlerMatcher = new UriPatternMatcher<>();
     }
 
     public Http2TestClient() throws IOException {
-        this(IOReactorConfig.DEFAULT);
+        this(IOReactorConfig.DEFAULT, null);
     }
 
     private AsyncPushConsumer createHandler(final HttpRequest request) throws HttpException {
@@ -138,7 +142,8 @@ public class Http2TestClient extends Asy
 
                 },
                 StandardCharsets.US_ASCII,
-                h2Config));
+                h2Config,
+                sslContext));
     }
 
     public void start(final H2Config h2Config) throws IOException {
@@ -150,12 +155,12 @@ public class Http2TestClient extends Asy
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit,
             final FutureCallback<ClientEndpoint> callback) throws InterruptedException {
         final BasicFuture<ClientEndpoint> future = new BasicFuture<>(callback);
-        requestSession(address, timeout, timeUnit, new SessionRequestCallback() {
+        requestSession(remoteEndpoint, timeout, timeUnit, new SessionRequestCallback() {
 
             @Override
             public void completed(final SessionRequest request) {
@@ -182,10 +187,10 @@ public class Http2TestClient extends Asy
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit) throws InterruptedException {
-        return connect(address, timeout, timeUnit, null);
+        return connect(remoteEndpoint, timeout, timeUnit, null);
     }
 
     public Future<ClientEndpoint> connect(
@@ -193,7 +198,7 @@ public class Http2TestClient extends Asy
             final int port,
             final long timeout,
             final TimeUnit timeUnit) throws InterruptedException {
-        return connect(new InetSocketAddress(hostname, port), timeout, timeUnit);
+        return connect(new HttpHost(hostname, port), timeout, timeUnit);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java Sun Nov 13 14:06:33 2016
@@ -31,6 +31,8 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.charset.StandardCharsets;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.http.ExceptionListener;
 import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncServer;
 import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncServerExchangeHandlerRegistry;
@@ -53,9 +55,10 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.Logger;
 public class Http2TestServer extends AsyncServer {
 
+    private final SSLContext sslContext;
     private final AsyncServerExchangeHandlerRegistry handlerRegistry;
 
-    public Http2TestServer(final IOReactorConfig ioReactorConfig) throws IOException {
+    public Http2TestServer(final IOReactorConfig ioReactorConfig, final SSLContext sslContext) throws IOException {
         super(ioReactorConfig, new ExceptionListener() {
 
             private final Logger log = LogManager.getLogger(Http2TestServer.class);
@@ -73,11 +76,12 @@ public class Http2TestServer extends Asy
             }
 
         });
+        this.sslContext = sslContext;
         this.handlerRegistry = new AsyncServerExchangeHandlerRegistry("localhost");
     }
 
     public Http2TestServer() throws IOException {
-        this(IOReactorConfig.DEFAULT);
+        this(IOReactorConfig.DEFAULT, null);
     }
 
     public InetSocketAddress start() throws Exception {
@@ -111,7 +115,8 @@ public class Http2TestServer extends Asy
                 httpProcessor,
                 handlerRegistry,
                 StandardCharsets.US_ASCII,
-                h2Config));
+                h2Config,
+                sslContext));
         final ListenerEndpoint listener = listen(new InetSocketAddress(0));
         listener.waitFor();
         return (InetSocketAddress) listener.getAddress();

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.testing.nio.
 import java.nio.charset.Charset;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.HttpConnection;
 import org.apache.hc.core5.http.impl.nio.ConnectionListener;
@@ -42,6 +44,7 @@ import org.apache.hc.core5.http2.impl.ni
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
 import org.apache.hc.core5.testing.nio.LoggingIOSession;
 import org.apache.hc.core5.util.Args;
@@ -56,21 +59,27 @@ class InternalClientHttp2EventHandlerFac
     private final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory;
     private final Charset charset;
     private final H2Config h2Config;
+    private final SSLContext sslContext;
 
     InternalClientHttp2EventHandlerFactory(
             final HttpProcessor httpProcessor,
             final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
             final Charset charset,
-            final H2Config h2Config) {
+            final H2Config h2Config,
+            final SSLContext sslContext) {
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.exchangeHandlerFactory = exchangeHandlerFactory;
         this.charset = charset;
         this.h2Config = h2Config;
+        this.sslContext = sslContext;
     }
 
     @Override
     public IOEventHandler createHandler(final IOSession ioSession) {
         final String id = "http2-outgoing-" + COUNT.incrementAndGet();
+        if (sslContext != null && ioSession instanceof TlsCapable) {
+            ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+        }
         final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
         return new LoggingIOEventHandler(new ClientHttpProtocolNegotiator(
                 ioSession, httpProcessor, exchangeHandlerFactory, charset, h2Config,

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalHttp2StreamListener.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalHttp2StreamListener.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalHttp2StreamListener.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalHttp2StreamListener.java Sun Nov 13 14:06:33 2016
@@ -50,9 +50,9 @@ class InternalHttp2StreamListener implem
         this.id = id;
         this.framePrinter = new FramePrinter();
         this.headerLog = LogManager.getLogger("org.apache.hc.core5.http.headers");
-        this.frameLog = LogManager.getLogger("org.apache.hc.core5.http.frame");
-        this.framePayloadLog = LogManager.getLogger("org.apache.hc.core5.http.frame.payload");
-        this.flowCtrlLog = LogManager.getLogger("org.apache.hc.core5.http.flow");
+        this.frameLog = LogManager.getLogger("org.apache.hc.core5.http2.frame");
+        this.framePayloadLog = LogManager.getLogger("org.apache.hc.core5.http2.frame.payload");
+        this.flowCtrlLog = LogManager.getLogger("org.apache.hc.core5.http2.flow");
     }
 
     private void logFrameInfo(final String prefix, final RawFrame frame) {

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.testing.nio.
 import java.nio.charset.Charset;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.HttpConnection;
 import org.apache.hc.core5.http.impl.nio.ConnectionListener;
@@ -42,6 +44,7 @@ import org.apache.hc.core5.http2.impl.ni
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
 import org.apache.hc.core5.testing.nio.LoggingIOSession;
 import org.apache.hc.core5.util.Args;
@@ -56,21 +59,27 @@ class InternalServerHttp2EventHandlerFac
     private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
     private final Charset charset;
     private final H2Config h2Config;
+    private final SSLContext sslContext;
 
     public InternalServerHttp2EventHandlerFactory(
             final HttpProcessor httpProcessor,
             final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
             final Charset charset,
-            final H2Config h2Config) {
+            final H2Config h2Config,
+            final SSLContext sslContext) {
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
         this.charset = charset;
         this.h2Config = h2Config;
+        this.sslContext = sslContext;
     }
 
     @Override
     public IOEventHandler createHandler(final IOSession ioSession) {
         final String id = "http2-incoming-" + COUNT.incrementAndGet();
+        if (sslContext != null && ioSession instanceof TlsCapable) {
+            ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+        }
         final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
         return new LoggingIOEventHandler(new ServerHttpProtocolNegotiator(
                 ioSession, httpProcessor, exchangeHandlerFactory, charset, h2Config,

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java Sun Nov 13 14:06:33 2016
@@ -42,6 +42,8 @@ import java.nio.ByteBuffer;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
@@ -60,6 +62,7 @@ import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpConnection;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHeaders;
+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.HttpStatus;
@@ -110,23 +113,42 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.http.protocol.RequestContent;
 import org.apache.hc.core5.http.protocol.RequestValidateHost;
 import org.apache.hc.core5.reactor.IOEventHandler;
+import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.SessionRequest;
+import org.apache.hc.core5.testing.ProtocolScheme;
 import org.apache.hc.core5.util.CharArrayBuffer;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
+@RunWith(Parameterized.class)
 public class Http1IntegrationTest extends InternalServerTestBase {
 
+    @Parameterized.Parameters(name = "{0}")
+    public static Collection<Object[]> protocols() {
+        return Arrays.asList(new Object[][]{
+                { ProtocolScheme.HTTP },
+                { ProtocolScheme.HTTPS }
+        });
+    }
+
+    public Http1IntegrationTest(final ProtocolScheme scheme) {
+        super(scheme);
+    }
+
     private static final long TIMEOUT = 5;
 
     private Http1TestClient client;
 
     @Before
     public void setup() throws Exception {
-        client = new Http1TestClient();
+        client = new Http1TestClient(
+                IOReactorConfig.DEFAULT,
+                scheme == ProtocolScheme.HTTPS ? createClientSSLContext() : null);
     }
 
     @After
@@ -679,7 +701,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final SessionRequest sessionRequest = client.requestSession(
-                new InetSocketAddress("localhost", serverEndpoint.getPort()), TIMEOUT, TimeUnit.SECONDS, null);
+                new HttpHost("localhost", serverEndpoint.getPort()), TIMEOUT, TimeUnit.SECONDS, null);
         sessionRequest.waitFor();
         final IOSession ioSession = sessionRequest.getSession();
         final ClientEndpoint streamEndpoint = new ClientEndpointImpl(ioSession);
@@ -1328,7 +1350,8 @@ public class Http1IntegrationTest extend
                 },
                 H1Config.DEFAULT,
                 ConnectionConfig.DEFAULT,
-                DefaultConnectionReuseStrategy.INSTANCE) {
+                DefaultConnectionReuseStrategy.INSTANCE,
+                scheme == ProtocolScheme.HTTPS ? createServerSSLContext() : null) {
 
             @Override
             protected ServerHttp1StreamDuplexer createServerHttp1StreamDuplexer(
@@ -1383,7 +1406,6 @@ public class Http1IntegrationTest extend
         } catch (final ExecutionException ex) {
             final Throwable cause = ex.getCause();
             Assert.assertTrue(cause instanceof MalformedChunkCodingException);
-            Assert.assertTrue(responseConsumer.getException() instanceof MalformedChunkCodingException);
             Assert.assertEquals("garbage", responseConsumer.getResponseContent());
         }
     }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java Sun Nov 13 14:06:33 2016
@@ -27,13 +27,29 @@
 
 package org.apache.hc.core5.testing.nio.http;
 
+import java.net.URL;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SSLContext;
+
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.testing.ProtocolScheme;
 import org.junit.Rule;
 import org.junit.rules.ExternalResource;
 
 public abstract class InternalServerTestBase {
 
+    protected final ProtocolScheme scheme;
+
+    public InternalServerTestBase(final ProtocolScheme scheme) {
+        this.scheme = scheme;
+    }
+
+    public InternalServerTestBase() {
+        this(ProtocolScheme.HTTP);
+    }
+
     protected Http1TestServer server;
 
     @Rule
@@ -41,7 +57,9 @@ public abstract class InternalServerTest
 
         @Override
         protected void before() throws Throwable {
-            server = new Http1TestServer();
+            server = new Http1TestServer(
+                    IOReactorConfig.DEFAULT,
+                    scheme == ProtocolScheme.HTTPS ? createServerSSLContext() : null);
         }
 
         @Override
@@ -57,4 +75,21 @@ public abstract class InternalServerTest
 
     };
 
+    protected SSLContext createServerSSLContext() throws Exception {
+        final URL keyStoreURL = getClass().getResource("/test.keystore");
+        final String storePassword = "nopassword";
+        return SSLContextBuilder.create()
+                .loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
+                .loadKeyMaterial(keyStoreURL, storePassword.toCharArray(), storePassword.toCharArray())
+                .build();
+    }
+
+    protected SSLContext createClientSSLContext() throws Exception {
+        final URL keyStoreURL = getClass().getResource("/test.keystore");
+        final String storePassword = "nopassword";
+        return SSLContextBuilder.create()
+                .loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
+                .build();
+    }
+
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java Sun Nov 13 14:06:33 2016
@@ -41,6 +41,8 @@ import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
@@ -86,6 +88,8 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.http2.H2Error;
 import org.apache.hc.core5.http2.H2StreamResetException;
 import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.testing.ProtocolScheme;
 import org.apache.hc.core5.testing.nio.http.EchoHandler;
 import org.apache.hc.core5.testing.nio.http.MessageExchangeHandler;
 import org.apache.hc.core5.testing.nio.http.MultiLineEntityProducer;
@@ -95,16 +99,32 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
+@RunWith(Parameterized.class)
 public class Http2IntegrationTest extends InternalServerTestBase {
 
+    @Parameterized.Parameters(name = "{0}")
+    public static Collection<Object[]> protocols() {
+        return Arrays.asList(new Object[][]{
+                { ProtocolScheme.HTTP },
+                { ProtocolScheme.HTTPS }
+        });
+    }
+
+    public Http2IntegrationTest(final ProtocolScheme scheme) {
+        super(scheme);
+    }
+
     private static final long TIMEOUT = 5;
 
     private Http2TestClient client;
 
     @Before
     public void setup() throws Exception {
-        client = new Http2TestClient();
+        client = new Http2TestClient(IOReactorConfig.DEFAULT,
+                scheme == ProtocolScheme.HTTPS ? createClientSSLContext() : null);
     }
 
     @After

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java Sun Nov 13 14:06:33 2016
@@ -27,13 +27,29 @@
 
 package org.apache.hc.core5.testing.nio.http2;
 
+import java.net.URL;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SSLContext;
+
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.testing.ProtocolScheme;
 import org.junit.Rule;
 import org.junit.rules.ExternalResource;
 
 public abstract class InternalServerTestBase {
 
+    protected final ProtocolScheme scheme;
+
+    public InternalServerTestBase(final ProtocolScheme scheme) {
+        this.scheme = scheme;
+    }
+
+    public InternalServerTestBase() {
+        this(ProtocolScheme.HTTP);
+    }
+
     protected Http2TestServer server;
 
     @Rule
@@ -41,7 +57,8 @@ public abstract class InternalServerTest
 
         @Override
         protected void before() throws Throwable {
-            server = new Http2TestServer();
+            server = new Http2TestServer(IOReactorConfig.DEFAULT,
+                    scheme == ProtocolScheme.HTTPS ? createServerSSLContext() : null);
         }
 
         @Override
@@ -57,4 +74,21 @@ public abstract class InternalServerTest
 
     };
 
+    protected SSLContext createServerSSLContext() throws Exception {
+        final URL keyStoreURL = getClass().getResource("/test.keystore");
+        final String storePassword = "nopassword";
+        return SSLContextBuilder.create()
+                .loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
+                .loadKeyMaterial(keyStoreURL, storePassword.toCharArray(), storePassword.toCharArray())
+                .build();
+    }
+
+    protected SSLContext createClientSSLContext() throws Exception {
+        final URL keyStoreURL = getClass().getResource("/test.keystore");
+        final String storePassword = "nopassword";
+        return SSLContextBuilder.create()
+                .loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
+                .build();
+    }
+
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2-debug.xml.template (from r1769014, httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2-debug.xml.template?p2=httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2-debug.xml.template&p1=httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml&r1=1769014&r2=1769496&rev=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2-debug.xml.template Sun Nov 13 14:06:33 2016
@@ -16,14 +16,20 @@
  limitations under the License.
 -->
 <Configuration status="WARN" name="XMLConfigTest">
-  <Appenders>
-    <Console name="STDOUT">
-      <PatternLayout pattern="%d %-5level [%t][%logger]%notEmpty{[%markerSimpleName]} %msg%n%xThrowable" />
-    </Console>
-  </Appenders>
-  <Loggers>
-    <Root level="WARN">
-      <AppenderRef ref="STDOUT" />
-    </Root>
-  </Loggers>
+    <Appenders>
+        <Console name="STDOUT">
+            <PatternLayout pattern="%d %-5level [%t][%logger]%notEmpty{[%markerSimpleName]} %msg%n%xThrowable"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="warn">
+            <AppenderRef ref="STDOUT"/>
+        </Root>
+        <Logger name="org.apache.hc.core5.reactor" level="debug"/>
+        <Logger name="org.apache.hc.core5.http.headers" level="debug"/>
+        <Logger name="org.apache.hc.core5.http.wire" level="error"/>
+        <Logger name="org.apache.hc.core5.http2.frame" level="debug"/>
+        <Logger name="org.apache.hc.core5.http2.frame.payload" level="error"/>
+        <Logger name="org.apache.hc.core5.http2.flow" level="debug"/>
+    </Loggers>
 </Configuration>
\ No newline at end of file

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/log4j2.xml Sun Nov 13 14:06:33 2016
@@ -22,7 +22,7 @@
     </Console>
   </Appenders>
   <Loggers>
-    <Root level="WARN">
+    <Root level="fatal">
       <AppenderRef ref="STDOUT" />
     </Root>
   </Loggers>

Added: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/test.keystore
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/test.keystore?rev=1769496&view=auto
==============================================================================
Binary files httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/test.keystore (added) and httpcomponents/httpcore/trunk/httpcore5-testing/src/test/resources/test.keystore Sun Nov 13 14:06:33 2016 differ

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java Sun Nov 13 14:06:33 2016
@@ -542,6 +542,10 @@ public class AsyncReverseProxyExample {
         }
 
         @Override
+        public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
+        }
+
+        @Override
         public void consumeResponse(
                 final HttpResponse incomingResponse,
                 final EntityDetails entityDetails) throws HttpException, IOException {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java Sun Nov 13 14:06:33 2016
@@ -33,6 +33,7 @@ import java.util.Locale;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.LangUtils;
 
@@ -44,7 +45,7 @@ import org.apache.hc.core5.util.LangUtil
  * @since 4.0
  */
 @Contract(threading = ThreadingBehavior.IMMUTABLE)
-public final class HttpHost implements Serializable {
+public final class HttpHost implements NamedEndpoint, Serializable {
 
     private static final long serialVersionUID = -7529410654042457626L;
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java Sun Nov 13 14:06:33 2016
@@ -39,6 +39,8 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.HttpConnection;
 import org.apache.hc.core5.http.HttpConnectionMetrics;
@@ -65,10 +67,14 @@ import org.apache.hc.core5.net.InetAddre
 import org.apache.hc.core5.reactor.Command;
 import org.apache.hc.core5.reactor.EventMask;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
+import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
+import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
+import org.apache.hc.core5.reactor.ssl.TlsCapable;
 import org.apache.hc.core5.util.Args;
 
 abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
-        implements ResourceHolder, HttpConnection {
+        implements ResourceHolder, HttpConnection, TlsCapable {
 
     private enum ConnectionState { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN}
 
@@ -120,7 +126,7 @@ abstract class AbstractHttp1StreamDuplex
         try {
             terminate(exception);
         } finally {
-            ioSession.shutdown();
+            ioSession.close();
         }
     }
 
@@ -438,6 +444,28 @@ abstract class AbstractHttp1StreamDuplex
         }
     }
 
+    @Override
+    public void startTls(
+            final SSLContext sslContext,
+            final SSLBufferManagement sslBufferManagement,
+            final SSLSessionInitializer initializer,
+            final SSLSessionVerifier verifier) throws UnsupportedOperationException {
+        if (ioSession instanceof TlsCapable) {
+            ((TlsCapable) ioSession).startTls(sslContext, sslBufferManagement, initializer, verifier);
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public boolean isTlsActive() {
+        if (ioSession instanceof TlsCapable) {
+            return ((TlsCapable) ioSession).isTlsActive();
+        } else {
+            return false;
+        }
+    }
+
     @Override
     public void close() throws IOException {
         ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncRequester.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncRequester.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncRequester.java Sun Nov 13 14:06:33 2016
@@ -28,12 +28,12 @@
 package org.apache.hc.core5.http.impl.nio.bootstrap;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.http.ExceptionListener;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
@@ -52,7 +52,7 @@ public class AsyncRequester extends IORe
         super(ioReactorConfig,
                 exceptionListener,
                 new ThreadFactoryImpl("connector", true),
-                new ThreadFactoryImpl("i/o dispatch", true),
+                new ThreadFactoryImpl("requester-dispatch", true),
                 sessionShutdownCallback);
     }
 
@@ -71,24 +71,24 @@ public class AsyncRequester extends IORe
     }
 
     protected SessionRequest requestSession(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit,
             final SessionRequestCallback callback) throws InterruptedException {
-        Args.notNull(address, "Address");
+        Args.notNull(remoteEndpoint, "Remote endpoint");
         Args.notNull(timeUnit, "Time unit");
-        final SessionRequest  sessionRequest = reactor().connect(address, null, null, callback);
+        final SessionRequest  sessionRequest = reactor().connect(remoteEndpoint, null, null, callback);
         sessionRequest.setConnectTimeout((int) timeUnit.toMillis(timeout));
         return sessionRequest;
     }
 
     @Override
     public SessionRequest connect(
-            final SocketAddress remoteAddress,
+            final NamedEndpoint remoteEndpoint,
             final SocketAddress localAddress,
             final Object attachment,
             final SessionRequestCallback callback) {
-        return reactor().connect(remoteAddress, localAddress, attachment, callback);
+        return reactor().connect(remoteEndpoint, localAddress, attachment, callback);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncServer.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/AsyncServer.java Sun Nov 13 14:06:33 2016
@@ -48,7 +48,7 @@ public class AsyncServer extends IOReact
         super(ioReactorConfig,
                 exceptionListener,
                 new ThreadFactoryImpl("listener"),
-                new ThreadFactoryImpl("i/o dispatch", true),
+                new ThreadFactoryImpl("server-dispatch", true),
                 sessionShutdownCallback);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java Sun Nov 13 14:06:33 2016
@@ -28,7 +28,6 @@
 package org.apache.hc.core5.http.impl.nio.bootstrap;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -36,9 +35,9 @@ import java.util.concurrent.TimeUnit;
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ExceptionListener;
-import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.nio.command.ShutdownCommand;
 import org.apache.hc.core5.http.nio.command.ShutdownType;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.IOSession;
@@ -74,14 +73,14 @@ public class HttpAsyncRequester extends
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit,
             final FutureCallback<ClientEndpoint> callback) throws InterruptedException {
-        Args.notNull(address, "Address");
+        Args.notNull(remoteEndpoint, "Remote endpoint");
         Args.notNull(timeUnit, "Time unit");
         final BasicFuture<ClientEndpoint> future = new BasicFuture<>(callback);
-        requestSession(address, timeout, timeUnit, new SessionRequestCallback() {
+        requestSession(remoteEndpoint, timeout, timeUnit, new SessionRequestCallback() {
 
             @Override
             public void completed(final SessionRequest request) {
@@ -108,21 +107,10 @@ public class HttpAsyncRequester extends
     }
 
     public Future<ClientEndpoint> connect(
-            final InetSocketAddress address,
+            final NamedEndpoint remoteEndpoint,
             final long timeout,
             final TimeUnit timeUnit) throws InterruptedException {
-        return connect(address, timeout, timeUnit, null);
-    }
-
-    public Future<ClientEndpoint> connect(
-            final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit) throws InterruptedException {
-        Args.notNull(host, "HTTP host");
-        final InetSocketAddress address = host.getAddress() != null ?
-                new InetSocketAddress(host.getAddress(), host.getPort()) :
-                new InetSocketAddress(host.getHostName(), host.getPort());
-        return connect(address, timeout, timeUnit);
+        return connect(remoteEndpoint, timeout, timeUnit, null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/pool/BasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/pool/BasicNIOConnPool.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/pool/BasicNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/pool/BasicNIOConnPool.java Sun Nov 13 14:06:33 2016
@@ -27,7 +27,6 @@
 package org.apache.hc.core5.http.impl.nio.pool;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -37,6 +36,7 @@ import org.apache.hc.core5.annotation.Co
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.pool.nio.AbstractNIOConnPool;
 import org.apache.hc.core5.pool.nio.NIOConnFactory;
 import org.apache.hc.core5.pool.nio.SocketAddressResolver;
@@ -71,17 +71,18 @@ public class BasicNIOConnPool extends Ab
         }
 
         @Override
-        public SocketAddress resolveRemoteAddress(final HttpHost host) {
+        public NamedEndpoint resolveRemoteEndpoint(final HttpHost host) {
+            final String schemeName = host.getSchemeName();
             final String hostname = host.getHostName();
             int port = host.getPort();
             if (port == -1) {
-                if (host.getSchemeName().equalsIgnoreCase("http")) {
+                if (schemeName.equalsIgnoreCase("http")) {
                     port = 80;
-                } else if (host.getSchemeName().equalsIgnoreCase("https")) {
+                } else if (schemeName.equalsIgnoreCase("https")) {
                     port = 443;
                 }
             }
-            return new InetSocketAddress(hostname, port);
+            return new HttpHost(hostname, port, schemeName);
         }
 
     }

Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/NamedEndpoint.java (from r1769014, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/NamedEndpoint.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/NamedEndpoint.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java&r1=1769014&r2=1769496&rev=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagementStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/NamedEndpoint.java Sun Nov 13 14:06:33 2016
@@ -24,19 +24,28 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.core5.reactor.ssl;
+
+package org.apache.hc.core5.net;
 
 /**
- * Encapsulates logic to manager SSL input/output buffers.
+ * Endpoint identified by name (usually a fully qualified domain name) and port.
+ *
+ * @since 5.0
  */
-public interface SSLBufferManagementStrategy {
+public interface NamedEndpoint {
+
+    /**
+     * Returns name (IP or DNS name).
+     *
+     * @return the host name (IP or DNS name)
+     */
+    String getHostName();
 
     /**
-     * Creates a {@link SSLBuffer} of {@code size}.
-     * @param size size of the buffer to create
-     * @return constructed buffer
-     * @throws IllegalArgumentException if {@code size} is not greater than {@code 0}
+     * Returns the port.
+     *
+     * @return the host port, or {@code -1} if not set
      */
-    SSLBuffer constructBuffer(int size);
+    int getPort();
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/AbstractNIOConnPool.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/AbstractNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/AbstractNIOConnPool.java Sun Nov 13 14:06:33 2016
@@ -47,6 +47,7 @@ import org.apache.hc.core5.annotation.Co
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.pool.ConnPool;
 import org.apache.hc.core5.pool.ConnPoolControl;
 import org.apache.hc.core5.pool.PoolEntry;
@@ -359,18 +360,17 @@ public abstract class AbstractNIOConnPoo
                 }
             }
 
+            final NamedEndpoint remoteEndpoint;
             final SocketAddress localAddress;
-            final SocketAddress remoteAddress;
             try {
-                remoteAddress = this.addressResolver.resolveRemoteAddress(route);
+                remoteEndpoint = this.addressResolver.resolveRemoteEndpoint(route);
                 localAddress = this.addressResolver.resolveLocalAddress(route);
             } catch (final IOException ex) {
                 request.failed(ex);
                 return false;
             }
-
             final SessionRequest sessionRequest = this.connectionInitiator.connect(
-                    remoteAddress, localAddress, route, this.sessionRequestCallback);
+                    remoteEndpoint, localAddress, route, this.sessionRequestCallback);
             final int timout = request.getConnectTimeout() < Integer.MAX_VALUE ?
                     (int) request.getConnectTimeout() : Integer.MAX_VALUE;
             sessionRequest.setConnectTimeout(timout);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/nio/SocketAddressResolver.java Sun Nov 13 14:06:33 2016
@@ -30,6 +30,8 @@ package org.apache.hc.core5.pool.nio;
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.hc.core5.net.NamedEndpoint;
+
 /**
  * Strategy that resolves an abstract connection route to a local or a remote {@link SocketAddress}.
  *
@@ -37,8 +39,8 @@ import java.net.SocketAddress;
  */
 public interface SocketAddressResolver<T> {
 
-    SocketAddress resolveLocalAddress(T route) throws IOException;
+    NamedEndpoint resolveRemoteEndpoint(T route) throws IOException;
 
-    SocketAddress resolveRemoteAddress(T route) throws IOException;
+    SocketAddress resolveLocalAddress(T route) throws IOException;
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionInitiator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionInitiator.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionInitiator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionInitiator.java Sun Nov 13 14:06:33 2016
@@ -29,6 +29,8 @@ package org.apache.hc.core5.reactor;
 
 import java.net.SocketAddress;
 
+import org.apache.hc.core5.net.NamedEndpoint;
+
 /**
  * Non-blocking connection initiator.
  *
@@ -61,15 +63,15 @@ public interface ConnectionInitiator {
      * to session requests, such as request completion, cancellation, failure or
      * timeout.
      *
-     * @param remoteAddress the socket address of the remote host.
-     * @param localAddress the local socket address. Can be {@code null},
+     * @param remoteEndpoint name of the remote host.
+     * @param localAddress local socket address. Can be {@code null},
      *    in which can the default local address and a random port will be used.
      * @param attachment the attachment object. Can be {@code null}.
      * @param callback interface. Can be {@code null}.
      * @return session request object.
      */
     SessionRequest connect(
-            SocketAddress remoteAddress,
+            NamedEndpoint remoteEndpoint,
             SocketAddress localAddress,
             Object attachment,
             SessionRequestCallback callback);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultConnectingIOReactor.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultConnectingIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultConnectingIOReactor.java Sun Nov 13 14:06:33 2016
@@ -40,6 +40,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ThreadFactory;
 
+import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.util.Asserts;
 
 /**
@@ -197,14 +198,15 @@ public class DefaultConnectingIOReactor
 
     @Override
     public SessionRequest connect(
-            final SocketAddress remoteAddress,
+            final NamedEndpoint remoteEndpoint,
             final SocketAddress localAddress,
             final Object attachment,
             final SessionRequestCallback callback) {
         final IOReactorStatus status = getStatus();
         Asserts.check(status == IOReactorStatus.INACTIVE || status == IOReactorStatus.ACTIVE, "I/O reactor has been shut down");
+        final InetSocketAddress remoteAddress = new InetSocketAddress(remoteEndpoint.getHostName(), remoteEndpoint.getPort());
         final SessionRequestImpl sessionRequest = new SessionRequestImpl(
-                remoteAddress, localAddress, attachment, callback);
+                remoteEndpoint, remoteAddress, localAddress, attachment, callback);
         sessionRequest.setConnectTimeout(this.reactorConfig.getConnectTimeout());
 
         this.requestQueue.add(sessionRequest);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java Sun Nov 13 14:06:33 2016
@@ -222,9 +222,13 @@ class IOReactorImpl implements IOReactor
             final ManagedIOSession session;
             try {
                 final SocketChannel socketChannel = pendingSession.socketChannel;
+                final SessionRequestImpl sessionRequest = pendingSession.sessionRequest;
                 socketChannel.configureBlocking(false);
                 final SelectionKey key = socketChannel.register(this.selector, SelectionKey.OP_READ);
-                session = new ManagedIOSession(new IOSessionImpl(key, socketChannel), closedSessions);
+                session = new ManagedIOSession(
+                        sessionRequest != null ?  sessionRequest.getRemoteEndpoint() : null,
+                        new IOSessionImpl(key, socketChannel),
+                        closedSessions);
                 session.setHandler(this.eventHandlerFactory.createHandler(session));
                 session.setSocketTimeout(this.reactorConfig.getSoTimeout());
                 key.attach(session);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java?rev=1769496&r1=1769495&r2=1769496&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java Sun Nov 13 14:06:33 2016
@@ -79,6 +79,7 @@ public interface IOSession {
      * @since 5.0
      */
     void addFirst(Command command);
+
     /**
      * Retrieves and removes first {@link Command} from the command queue.
      *