HTTPCLIENT-1254: Redirect with underscore in hostname causes ProtocolException
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1406286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b930227f90
commit
6293899e61
|
@ -1,7 +1,10 @@
|
|||
Changes in trunk
|
||||
-------------------
|
||||
|
||||
* [HTTPCLIENT-1255] AbstractVerifier incorrectly parses certificate CN containing wildcard
|
||||
* [HTTPCLIENT-1254] Redirect with underscore in hostname causes ProtocolException.
|
||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||
|
||||
* [HTTPCLIENT-1255] AbstractVerifier incorrectly parses certificate CN containing wildcard.
|
||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||
|
||||
* [HTTPCLIENT-1248] Default and lax redirect strategies should not convert requests redirected
|
||||
|
|
|
@ -1100,15 +1100,11 @@ public class DefaultRequestDirector implements RequestDirector {
|
|||
redirect.setHeaders(orig.getAllHeaders());
|
||||
|
||||
URI uri = redirect.getURI();
|
||||
if (uri.getHost() == null) {
|
||||
HttpHost newTarget = URIUtils.extractHost(uri);
|
||||
if (newTarget == null) {
|
||||
throw new ProtocolException("Redirect URI does not specify a valid host name: " + uri);
|
||||
}
|
||||
|
||||
HttpHost newTarget = new HttpHost(
|
||||
uri.getHost(),
|
||||
uri.getPort(),
|
||||
uri.getScheme());
|
||||
|
||||
// Reset auth states if redirecting to another host
|
||||
if (!route.getTargetHost().equals(newTarget)) {
|
||||
this.log.debug("Resetting target auth state");
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.http.client.methods.HttpExecutionAware;
|
|||
import org.apache.http.client.params.ClientPNames;
|
||||
import org.apache.http.client.params.HttpClientParams;
|
||||
import org.apache.http.client.protocol.ClientContext;
|
||||
import org.apache.http.client.utils.URIUtils;
|
||||
import org.apache.http.conn.routing.HttpRoute;
|
||||
import org.apache.http.conn.routing.HttpRoutePlanner;
|
||||
import org.apache.http.params.HttpParams;
|
||||
|
@ -128,13 +129,12 @@ class RedirectExec implements ClientExecChain {
|
|||
currentRequest.setParams(params);
|
||||
|
||||
URI uri = currentRequest.getURI();
|
||||
HttpHost newTarget = URIUtils.extractHost(uri);
|
||||
if (uri.getHost() == null) {
|
||||
throw new ProtocolException("Redirect URI does not specify a valid host name: " +
|
||||
uri);
|
||||
}
|
||||
|
||||
HttpHost newTarget = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
|
||||
|
||||
// Reset virtual host and auth states if redirecting to another host
|
||||
if (!currentRoute.getTargetHost().equals(newTarget)) {
|
||||
AuthState targetAuthState = (AuthState) context.getAttribute(
|
||||
|
|
Loading…
Reference in New Issue