Fixed IllegalArgumentException in URIUtils#extractHost thrown in case of host name containing blanks
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1625255 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe876f9656
commit
061f150ab1
|
@ -401,7 +401,10 @@ public class URIUtils {
|
||||||
}
|
}
|
||||||
final String scheme = uri.getScheme();
|
final String scheme = uri.getScheme();
|
||||||
if (!TextUtils.isBlank(host)) {
|
if (!TextUtils.isBlank(host)) {
|
||||||
target = new HttpHost(host, port, scheme);
|
try {
|
||||||
|
target = new HttpHost(host, port, scheme);
|
||||||
|
} catch (IllegalArgumentException ignore) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
|
|
|
@ -260,6 +260,8 @@ public class TestURIUtils {
|
||||||
URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
|
URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
|
||||||
Assert.assertEquals(null,
|
Assert.assertEquals(null,
|
||||||
URIUtils.extractHost(new URI("http://:80/robots.txt")));
|
URIUtils.extractHost(new URI("http://:80/robots.txt")));
|
||||||
|
Assert.assertEquals(null,
|
||||||
|
URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue