hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1382350 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl: client/InternalHttpClient.java client/exec/MainClientExec.java conn/DefaultClientConnectionOperator.java conn/DefaultHttpRoutePlanner.java
Date Sat, 08 Sep 2012 19:56:35 GMT
Author: olegk
Date: Sat Sep  8 19:56:35 2012
New Revision: 1382350

URL: http://svn.apache.org/viewvc?rev=1382350&view=rev
Log:
SchemeRegistry instance set in the execution context takes precedence over the default one
(related to HTTPASYNC-25)

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1382350&r1=1382349&r2=1382350&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
Sat Sep  8 19:56:35 2012
@@ -156,8 +156,9 @@ class InternalHttpClient extends Abstrac
             HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
             wrapper.setParams(params);
             wrapper.setVirtualHost(virtualHost);
-            HttpRoute route = determineRoute(target, wrapper, context);
-            return this.execChain.execute(route, wrapper, setupContext(context), execListner);
+            HttpContext localcontext = setupContext(context);
+            HttpRoute route = determineRoute(target, wrapper, localcontext);
+            return this.execChain.execute(route, wrapper, localcontext, execListner);
         } catch (HttpException httpException) {
             throw new ClientProtocolException(httpException);
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java?rev=1382350&r1=1382349&r2=1382350&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
Sat Sep  8 19:56:35 2012
@@ -62,6 +62,7 @@ import org.apache.http.conn.routing.Basi
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.HttpRouteDirector;
 import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.entity.BufferedHttpEntity;
 import org.apache.http.impl.client.HttpAuthenticator;
 import org.apache.http.impl.client.RequestAbortedException;
@@ -453,6 +454,15 @@ public class MainClientExec implements C
         } while (step > HttpRouteDirector.COMPLETE);
     }
 
+    private SchemeRegistry getSchemeRegistry(final HttpContext context) {
+        SchemeRegistry reg = (SchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.connManager.getSchemeRegistry();
+        }
+        return reg;
+    }
+    
     /**
      * Creates a tunnel to the target server.
      * The connection must be established to the (last) proxy.
@@ -476,8 +486,8 @@ public class MainClientExec implements C
         String host = target.getHostName();
         int port = target.getPort();
         if (port < 0) {
-            Scheme scheme = connManager.getSchemeRegistry().
-                getScheme(target.getSchemeName());
+            SchemeRegistry registry = getSchemeRegistry(context);
+            Scheme scheme = registry.getScheme(target.getSchemeName());
             port = scheme.getDefaultPort();
         }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java?rev=1382350&r1=1382349&r2=1382350&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
Sat Sep  8 19:56:35 2012
@@ -43,6 +43,7 @@ import org.apache.http.params.HttpParams
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.protocol.HttpContext;
 
+import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.HttpHostConnectException;
 import org.apache.http.conn.HttpInetSocketAddress;
@@ -137,6 +138,15 @@ public class DefaultClientConnectionOper
         return new DefaultClientConnection();
     }
 
+    private SchemeRegistry getSchemeRegistry(final HttpContext context) {
+        SchemeRegistry reg = (SchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.schemeRegistry;
+        }
+        return reg;
+    }
+    
     public void openConnection(
             final OperatedClientConnection conn,
             final HttpHost target,
@@ -156,7 +166,8 @@ public class DefaultClientConnectionOper
             throw new IllegalStateException("Connection must not be open");
         }
 
-        Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
+        SchemeRegistry registry = getSchemeRegistry(context);
+        Scheme schm = registry.getScheme(target.getSchemeName());
         SchemeSocketFactory sf = schm.getSchemeSocketFactory();
 
         InetAddress[] addresses = resolveHostname(target.getHostName());
@@ -219,7 +230,8 @@ public class DefaultClientConnectionOper
             throw new IllegalStateException("Connection must be open");
         }
 
-        final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
+        SchemeRegistry registry = getSchemeRegistry(context);
+        Scheme schm = registry.getScheme(target.getSchemeName());
         if (!(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory)) {
             throw new IllegalArgumentException
                 ("Target scheme (" + schm.getName() +

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java?rev=1382350&r1=1382349&r2=1382350&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
Sat Sep  8 19:56:35 2012
@@ -37,6 +37,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 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;
 import org.apache.http.conn.scheme.Scheme;
@@ -79,6 +80,15 @@ public class DefaultHttpRoutePlanner imp
         schemeRegistry = schreg;
     }
 
+    private SchemeRegistry getSchemeRegistry(final HttpContext context) {
+        SchemeRegistry reg = (SchemeRegistry) context.getAttribute(
+                ClientContext.SCHEME_REGISTRY);
+        if (reg == null) {
+            reg = this.schemeRegistry;
+        }
+        return reg;
+    }
+    
     public HttpRoute determineRoute(HttpHost target,
                                     HttpRequest request,
                                     HttpContext context)
@@ -110,7 +120,8 @@ public class DefaultHttpRoutePlanner imp
 
         final Scheme schm;
         try {
-            schm = schemeRegistry.getScheme(target.getSchemeName());
+            SchemeRegistry registry = getSchemeRegistry(context);
+            schm = registry.getScheme(target.getSchemeName());
         } catch (IllegalStateException ex) {
             throw new HttpException(ex.getMessage());
         }



Mime
View raw message