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;
|
protected final RedirectHandler redirectHandler;
|
||||||
|
|
||||||
/** The target authentication handler. */
|
/** The target authentication handler. */
|
||||||
private final AuthenticationHandler targetAuthHandler;
|
protected final AuthenticationHandler targetAuthHandler;
|
||||||
|
|
||||||
/** The proxy authentication handler. */
|
/** The proxy authentication handler. */
|
||||||
private final AuthenticationHandler proxyAuthHandler;
|
protected final AuthenticationHandler proxyAuthHandler;
|
||||||
|
|
||||||
/** The user token handler. */
|
/** The user token handler. */
|
||||||
private final UserTokenHandler userTokenHandler;
|
protected final UserTokenHandler userTokenHandler;
|
||||||
|
|
||||||
/** The HTTP parameters. */
|
/** The HTTP parameters. */
|
||||||
protected final HttpParams params;
|
protected final HttpParams params;
|
||||||
@ -179,13 +179,15 @@ public class DefaultRequestDirector implements RequestDirector {
|
|||||||
/** The currently allocated connection. */
|
/** The currently allocated connection. */
|
||||||
protected ManagedClientConnection managedConn;
|
protected ManagedClientConnection managedConn;
|
||||||
|
|
||||||
|
protected final AuthState targetAuthState;
|
||||||
|
|
||||||
|
protected final AuthState proxyAuthState;
|
||||||
|
|
||||||
private int redirectCount;
|
private int redirectCount;
|
||||||
|
|
||||||
private int maxRedirects;
|
private int maxRedirects;
|
||||||
|
|
||||||
private final AuthState targetAuthState;
|
private HttpHost virtualHost;
|
||||||
|
|
||||||
private final AuthState proxyAuthState;
|
|
||||||
|
|
||||||
public DefaultRequestDirector(
|
public DefaultRequestDirector(
|
||||||
final HttpRequestExecutor requestExec,
|
final HttpRequestExecutor requestExec,
|
||||||
@ -321,6 +323,9 @@ public HttpResponse execute(HttpHost target, HttpRequest request,
|
|||||||
origWrapper.setParams(params);
|
origWrapper.setParams(params);
|
||||||
HttpRoute origRoute = determineRoute(target, origWrapper, context);
|
HttpRoute origRoute = determineRoute(target, origWrapper, context);
|
||||||
|
|
||||||
|
virtualHost = (HttpHost) orig.getParams().getParameter(
|
||||||
|
ClientPNames.VIRTUAL_HOST);
|
||||||
|
|
||||||
RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
|
RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
|
||||||
|
|
||||||
long timeout = ConnManagerParams.getTimeout(params);
|
long timeout = ConnManagerParams.getTimeout(params);
|
||||||
@ -397,8 +402,7 @@ public HttpResponse execute(HttpHost target, HttpRequest request,
|
|||||||
rewriteRequestURI(wrapper, route);
|
rewriteRequestURI(wrapper, route);
|
||||||
|
|
||||||
// Use virtual host if set
|
// Use virtual host if set
|
||||||
target = (HttpHost) wrapper.getParams().getParameter(
|
target = virtualHost;
|
||||||
ClientPNames.VIRTUAL_HOST);
|
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
target = route.getTargetHost();
|
target = route.getTargetHost();
|
||||||
@ -930,6 +934,9 @@ protected RoutedRequest handleResponse(RoutedRequest roureq,
|
|||||||
}
|
}
|
||||||
redirectCount++;
|
redirectCount++;
|
||||||
|
|
||||||
|
// Virtual host cannot be used any longer
|
||||||
|
virtualHost = null;
|
||||||
|
|
||||||
URI uri = this.redirectHandler.getLocationURI(response, context);
|
URI uri = this.redirectHandler.getLocationURI(response, context);
|
||||||
|
|
||||||
HttpHost newTarget = new HttpHost(
|
HttpHost newTarget = new HttpHost(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user