HTTPCLIENT-711: Bad route computed for redirected requests

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@604433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2007-12-15 14:35:20 +00:00
parent f1f1a7a72c
commit d417db6bba
5 changed files with 9 additions and 22 deletions

View File

@ -1,6 +1,9 @@
Changes since 4.0 Alpha 2
-------------------
* [HTTPCLIENT-711] Bad route computed for redirected requests
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-705] Fixed incorrect handling of URIs with null path component
Contributed by Oleg Kalnichevski <olegk at apache.org>

View File

@ -34,7 +34,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.HttpRoute;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;

View File

@ -159,7 +159,7 @@ public class RequestAddCookies implements HttpRequestInterceptor {
}
}
// Generate Cookie request headers
if (cookies.length > 0) {
if (!matchedCookies.isEmpty()) {
List<Header> headers = cookieSpec.formatCookies(matchedCookies);
for (int i = 0; i < headers.size(); i++) {
request.addHeader(headers.get(i));

View File

@ -32,7 +32,6 @@
package org.apache.http.impl.client;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
@ -833,7 +832,6 @@ public class DefaultClientRequestDirector
HttpRoute route = roureq.getRoute();
HttpHost target = route.getTargetHost();
HttpHost proxy = route.getProxyHost();
InetAddress localAddress = route.getLocalAddress();
HttpParams params = request.getParams();
if (HttpClientParams.isRedirecting(params) &&
@ -852,24 +850,15 @@ public class DefaultClientRequestDirector
uri.getPort(),
uri.getScheme());
Scheme schm = connManager.getSchemeRegistry().
getScheme(newTarget.getSchemeName());
HttpRoute newRoute = new HttpRoute(
newTarget,
localAddress,
proxy,
schm.isLayered(),
(proxy != null),
(proxy != null));
HttpGet redirect = new HttpGet(uri);
redirect.setParams(params);
RoutedRequest newRequest = determineRoute(newTarget, redirect, context);
if (LOG.isDebugEnabled()) {
LOG.debug("Redirecting to '" + uri + "' via " + newRoute);
LOG.debug("Redirecting to '" + uri + "' via " + newRequest.getRoute());
}
return new RoutedRequest.Impl(redirect, newRoute);
return newRequest;
}
CredentialsProvider credsProvider = (CredentialsProvider)

View File

@ -32,9 +32,6 @@
package org.apache.http.impl.client;
import org.apache.http.ConnectionReuseStrategy;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpVersion;
import org.apache.http.auth.AuthSchemeRegistry;
import org.apache.http.client.AuthenticationHandler;
@ -43,8 +40,8 @@ import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.client.protocol.RequestAddCookies;
import org.apache.http.client.protocol.RequestDefaultHeaders;
@ -53,7 +50,6 @@ import org.apache.http.client.protocol.RequestTargetAuthentication;
import org.apache.http.client.protocol.ResponseProcessCookies;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionManagerFactory;
import org.apache.http.conn.HttpRoute;
import org.apache.http.conn.HttpRoutePlanner;
import org.apache.http.conn.PlainSocketFactory;
import org.apache.http.conn.Scheme;