Index: httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java =================================================================== --- httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java (revision 1381729) +++ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java (working copy) @@ -37,6 +37,7 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.RouteTracker; import org.apache.http.impl.conn.ConnectionShutdownException; @@ -44,6 +45,7 @@ import org.apache.http.nio.conn.ClientAsyncConnectionManager; import org.apache.http.nio.conn.ManagedClientAsyncConnection; import org.apache.http.nio.conn.ClientAsyncConnection; +import org.apache.http.nio.conn.scheme.AsyncSchemeRegistry; import org.apache.http.nio.conn.scheme.LayeringStrategy; import org.apache.http.nio.conn.scheme.AsyncScheme; import org.apache.http.nio.reactor.IOEventDispatch; @@ -284,6 +286,14 @@ } } + private AsyncSchemeRegistry getSchemeRegistry(HttpContext context) { + AsyncSchemeRegistry reg = (AsyncSchemeRegistry)context.getAttribute(ClientContext.SCHEME_REGISTRY); + if (reg != null) { + return reg; + } + return this.manager.getSchemeRegistry(); + } + public synchronized void open( final HttpRoute route, final HttpContext context, @@ -299,7 +309,7 @@ IOSession iosession = entry.getConnection(); if (proxy == null) { - AsyncScheme scheme = this.manager.getSchemeRegistry().getScheme(target); + AsyncScheme scheme = getSchemeRegistry(context).getScheme(target); LayeringStrategy layeringStrategy = scheme.getLayeringStrategy(); if (layeringStrategy != null) { iosession = layeringStrategy.layer(iosession); @@ -356,7 +366,7 @@ throw new IllegalStateException("Multiple protocol layering not supported"); } HttpHost target = tracker.getTargetHost(); - AsyncScheme scheme = this.manager.getSchemeRegistry().getScheme(target); + AsyncScheme scheme = getSchemeRegistry(context).getScheme(target); LayeringStrategy layeringStrategy = scheme.getLayeringStrategy(); if (layeringStrategy == null) { throw new IllegalStateException(scheme.getName() + Index: httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java =================================================================== --- httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java (revision 1381729) +++ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java (working copy) @@ -50,6 +50,10 @@ super(); this.schemeRegistry = schemeRegistry; } + + public AsyncSchemeRegistry getSchemeRegistry() { + return this.schemeRegistry; + } public HttpRoute determineRoute( final HttpHost target, Index: httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java =================================================================== --- httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (revision 1381729) +++ httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (working copy) @@ -73,6 +73,7 @@ import org.apache.http.impl.client.HttpAuthenticator; import org.apache.http.impl.client.RequestWrapper; import org.apache.http.impl.client.RoutedRequest; +import org.apache.http.impl.nio.conn.DefaultHttpAsyncRoutePlanner; import org.apache.http.message.BasicHttpRequest; import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.ContentEncoder; @@ -80,6 +81,7 @@ import org.apache.http.nio.conn.ClientAsyncConnectionManager; import org.apache.http.nio.conn.ManagedClientAsyncConnection; import org.apache.http.nio.conn.scheme.AsyncScheme; +import org.apache.http.nio.conn.scheme.AsyncSchemeRegistry; import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler; import org.apache.http.nio.protocol.HttpAsyncRequestExecutor; import org.apache.http.nio.protocol.HttpAsyncRequestProducer; @@ -675,6 +677,13 @@ } } + private AsyncSchemeRegistry getSchemeRegistry() { + if (routePlanner instanceof DefaultHttpAsyncRoutePlanner) { + return ((DefaultHttpAsyncRoutePlanner)routePlanner).getSchemeRegistry(); + } + return this.connmgr.getSchemeRegistry(); + } + private HttpRequest createConnectRequest(final HttpRoute route) { // see RFC 2817, section 5.2 and // INTERNET-DRAFT: Tunneling TCP based protocols through @@ -683,7 +692,7 @@ String host = target.getHostName(); int port = target.getPort(); if (port < 0) { - AsyncScheme scheme = this.connmgr.getSchemeRegistry().getScheme(target.getSchemeName()); + AsyncScheme scheme = getSchemeRegistry().getScheme(target.getSchemeName()); port = scheme.getDefaultPort(); } StringBuilder buffer = new StringBuilder(host.length() + 6); Index: httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java =================================================================== --- httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java (revision 1381729) +++ httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java (working copy) @@ -195,6 +195,11 @@ protected void initializeEngine(final SSLEngine engine) { } + protected void verifySession(final IOSession iosession, + final SSLSession sslsession) throws SSLException { + InetSocketAddress address = (InetSocketAddress) iosession.getRemoteAddress(); + hostnameVerifier.verify(address.getHostName(), sslsession); + } class InternalSSLSetupHandler implements SSLSetupHandler { @@ -206,8 +211,7 @@ public void verify( final IOSession iosession, final SSLSession sslsession) throws SSLException { - InetSocketAddress address = (InetSocketAddress) iosession.getRemoteAddress(); - hostnameVerifier.verify(address.getHostName(), sslsession); + verifySession(iosession, sslsession); } }