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:
Oleg Kalnichevski 2014-09-16 12:07:44 +00:00
parent fe876f9656
commit 061f150ab1
2 changed files with 6 additions and 1 deletions

View File

@ -401,7 +401,10 @@ public class URIUtils {
}
final String scheme = uri.getScheme();
if (!TextUtils.isBlank(host)) {
target = new HttpHost(host, port, scheme);
try {
target = new HttpHost(host, port, scheme);
} catch (IllegalArgumentException ignore) {
}
}
}
return target;

View File

@ -260,6 +260,8 @@ public class TestURIUtils {
URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://:80/robots.txt")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
}
@Test