Remove user info from request URI when rewriting

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1351478 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-06-18 20:27:59 +00:00
parent 2e3efc7d27
commit ddde53711c
2 changed files with 4 additions and 2 deletions

View File

@ -189,8 +189,8 @@ public class URIUtils {
if (uri == null) {
throw new IllegalArgumentException("URI may not be null");
}
if (uri.getFragment() != null) {
return new URIBuilder(uri).setFragment(null).build();
if (uri.getFragment() != null || uri.getUserInfo() != null) {
return new URIBuilder(uri).setFragment(null).setUserInfo(null).build();
} else {
return uri;
}

View File

@ -60,6 +60,8 @@ public class TestURIUtils {
URI.create("http://thathost/stuff")).toString());
Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(
URI.create("http://thathost/stuff#fragment")).toString());
Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(
URI.create("http://userinfo@thathost/stuff#fragment")).toString());
}
@Test