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 2009/05/31 12:35:47 UTC

svn commit: r780403 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java

Author: olegk
Date: Sun May 31 10:35:47 2009
New Revision: 780403

URL: http://svn.apache.org/viewvc?rev=780403&view=rev
Log:
Fixed handling of the virtual host parameter. Virtual host parameter should not be used if the request has been redirected. 

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java?rev=780403&r1=780402&r2=780403&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java Sun May 31 10:35:47 2009
@@ -165,13 +165,13 @@
     protected final RedirectHandler redirectHandler;
     
     /** The target authentication handler. */
-    private final AuthenticationHandler targetAuthHandler;
+    protected final AuthenticationHandler targetAuthHandler;
     
     /** The proxy authentication handler. */
-    private final AuthenticationHandler proxyAuthHandler;
+    protected final AuthenticationHandler proxyAuthHandler;
     
     /** The user token handler. */
-    private final UserTokenHandler userTokenHandler;
+    protected final UserTokenHandler userTokenHandler;
     
     /** The HTTP parameters. */
     protected final HttpParams params;
@@ -179,13 +179,15 @@
     /** The currently allocated connection. */
     protected ManagedClientConnection managedConn;
 
+    protected final AuthState targetAuthState;
+    
+    protected final AuthState proxyAuthState;
+    
     private int redirectCount;
 
     private int maxRedirects;
     
-    private final AuthState targetAuthState;
-    
-    private final AuthState proxyAuthState;
+    private HttpHost virtualHost;
     
     public DefaultRequestDirector(
             final HttpRequestExecutor requestExec,
@@ -321,6 +323,9 @@
         origWrapper.setParams(params);
         HttpRoute origRoute = determineRoute(target, origWrapper, context);
 
+        virtualHost = (HttpHost) orig.getParams().getParameter(
+                ClientPNames.VIRTUAL_HOST);
+        
         RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute); 
 
         long timeout = ConnManagerParams.getTimeout(params);
@@ -397,8 +402,7 @@
                 rewriteRequestURI(wrapper, route);
 
                 // Use virtual host if set
-                target = (HttpHost) wrapper.getParams().getParameter(
-                        ClientPNames.VIRTUAL_HOST);
+                target = virtualHost;
 
                 if (target == null) {
                     target = route.getTargetHost();
@@ -930,6 +934,9 @@
             }
             redirectCount++;
             
+            // Virtual host cannot be used any longer
+            virtualHost = null;
+            
             URI uri = this.redirectHandler.getLocationURI(response, context);
 
             HttpHost newTarget = new HttpHost(