hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1382345 - in /httpcomponents/httpasyncclient/trunk: ./ httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/
Date Sat, 08 Sep 2012 19:34:38 GMT
Author: olegk
Date: Sat Sep  8 19:34:37 2012
New Revision: 1382345

URL: http://svn.apache.org/viewvc?rev=1382345&view=rev
Log:
HTTPASYNC-25: AsyncSchemeRegistry instance set in the execution context takes precedence over
the default one
Contributed by Daniel Kulp <dkulp at apache.org>

Modified:
    httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java

Modified: httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt?rev=1382345&r1=1382344&r2=1382345&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt Sat Sep  8 19:34:37 2012
@@ -1,3 +1,11 @@
+Changes since 4.0 Beta 2
+-------------------
+
+* [HTTPASYNC-25] AsyncSchemeRegistry instance set in the execution context takes precedence
over
+  the default one.
+  Contributed by Daniel Kulp <dkulp at apache.org> 
+
+
 Release 4.0 Beta 2
 -------------------
 

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1382345&r1=1382344&r2=1382345&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
Sat Sep  8 19:34:37 2012
@@ -80,6 +80,7 @@ import org.apache.http.nio.IOControl;
 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 +676,15 @@ class DefaultAsyncRequestDirector<T> imp
         }
     }
 
+    private AsyncSchemeRegistry getSchemeRegistry(final HttpContext context) {
+        AsyncSchemeRegistry reg = (AsyncSchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.connmgr.getSchemeRegistry();
+        }
+        return reg;
+    }
+    
     private HttpRequest createConnectRequest(final HttpRoute route) {
         // see RFC 2817, section 5.2 and
         // INTERNET-DRAFT: Tunneling TCP based protocols through
@@ -683,7 +693,8 @@ class DefaultAsyncRequestDirector<T> imp
         String host = target.getHostName();
         int port = target.getPort();
         if (port < 0) {
-            AsyncScheme scheme = this.connmgr.getSchemeRegistry().getScheme(target.getSchemeName());
+            AsyncSchemeRegistry registry = getSchemeRegistry(this.localContext);
+            AsyncScheme scheme = registry.getScheme(target.getSchemeName());
             port = scheme.getDefaultPort();
         }
         StringBuilder buffer = new StringBuilder(host.length() + 6);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java?rev=1382345&r1=1382344&r2=1382345&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
Sat Sep  8 19:34:37 2012
@@ -37,6 +37,7 @@ import org.apache.http.nio.conn.scheme.A
 import org.apache.http.nio.conn.scheme.AsyncSchemeRegistry;
 import org.apache.http.protocol.HttpContext;
 
+import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.HttpRoutePlanner;
 
@@ -51,6 +52,15 @@ public class DefaultHttpAsyncRoutePlanne
         this.schemeRegistry = schemeRegistry;
     }
 
+    private AsyncSchemeRegistry getSchemeRegistry(final HttpContext context) {
+        AsyncSchemeRegistry reg = (AsyncSchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.schemeRegistry;
+        }
+        return reg;
+    }
+    
     public HttpRoute determineRoute(
             final HttpHost target,
             final HttpRequest request,
@@ -69,7 +79,8 @@ public class DefaultHttpAsyncRoutePlanne
         HttpHost proxy = ConnRouteParams.getDefaultProxy(request.getParams());
         AsyncScheme scheme;
         try {
-            scheme = this.schemeRegistry.getScheme(target);
+            AsyncSchemeRegistry registry = getSchemeRegistry(context);
+            scheme = registry.getScheme(target);
         } catch (IllegalStateException ex) {
             throw new HttpException(ex.getMessage());
         }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java?rev=1382345&r1=1382344&r2=1382345&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientAsyncConnectionImpl.java
Sat Sep  8 19:34:37 2012
@@ -37,6 +37,7 @@ import org.apache.http.HttpException;
 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.ClientAs
 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,15 @@ class ManagedClientAsyncConnectionImpl i
         }
     }
 
+    private AsyncSchemeRegistry getSchemeRegistry(final HttpContext context) {
+        AsyncSchemeRegistry reg = (AsyncSchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.manager.getSchemeRegistry();
+        }
+        return reg;
+    }
+    
     public synchronized void open(
             final HttpRoute route,
             final HttpContext context, 
@@ -299,7 +310,7 @@ class ManagedClientAsyncConnectionImpl i
         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 +367,7 @@ class ManagedClientAsyncConnectionImpl i
             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() +

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java?rev=1382345&r1=1382344&r2=1382345&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
Sat Sep  8 19:34:37 2012
@@ -195,6 +195,11 @@ public class SSLLayeringStrategy impleme
 
     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 class SSLLayeringStrategy impleme
         public void verify(
                 final IOSession iosession,
                 final SSLSession sslsession) throws SSLException {
-            InetSocketAddress address = (InetSocketAddress) iosession.getRemoteAddress();
-            hostnameVerifier.verify(address.getHostName(), sslsession);
+            verifySession(iosession, sslsession);
         }
 
     }



Mime
View raw message