mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-25 03:38:04 +00:00
Fixed handling of the virtual host parameter. Virtual host parameter should not be used if the request has been redirected.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@780403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b1db46db6c
commit
7d39f392f6
@ -165,13 +165,13 @@ public class DefaultRequestDirector implements RequestDirector {
|
||||
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 @@ public class DefaultRequestDirector implements RequestDirector {
|
||||
/** 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 @@ public HttpResponse execute(HttpHost target, HttpRequest request,
|
||||
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 @@ public HttpResponse execute(HttpHost target, HttpRequest request,
|
||||
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 @@ protected RoutedRequest handleResponse(RoutedRequest roureq,
|
||||
}
|
||||
redirectCount++;
|
||||
|
||||
// Virtual host cannot be used any longer
|
||||
virtualHost = null;
|
||||
|
||||
URI uri = this.redirectHandler.getLocationURI(response, context);
|
||||
|
||||
HttpHost newTarget = new HttpHost(
|
||||
|
Loading…
x
Reference in New Issue
Block a user