HTTPCLIENT-1498: empty host in redirect location causes NPE

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1591221 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-04-30 09:32:52 +00:00
parent 92b5d6d09d
commit b40661e45e
2 changed files with 3 additions and 1 deletions

View File

@ -366,7 +366,7 @@ public class URIUtils {
}
}
final String scheme = uri.getScheme();
if (host != null) {
if (!TextUtils.isBlank(host)) {
target = new HttpHost(host, port, scheme);
}
}

View File

@ -229,6 +229,8 @@ public class TestURIUtils {
URIUtils.extractHost(new URI("http://localhost:8080;sessionid=stuff/abcd")));
Assert.assertEquals(new HttpHost("localhost",-1),
URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://:80/robots.txt")));
}
@Test