HTTPCLIENT-1440: 'file' scheme in redirect location URI causes NPE.
Contributed by James Leigh <james at 3roundstones dot com> git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1546315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
037b915bd0
commit
9cc7c1acec
|
@ -1,6 +1,9 @@
|
|||
Changes since 4.3.1
|
||||
-------------------
|
||||
|
||||
* [HTTPCLIENT-1440] 'file' scheme in redirect location URI causes NPE.
|
||||
Contributed by James Leigh <james at 3roundstones dot com>
|
||||
|
||||
* [HTTPCLIENT-1437] Made Executor#execute thread safe.
|
||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||
|
||||
|
|
|
@ -259,7 +259,8 @@ public class URIUtils {
|
|||
* @return the URI without dot segments
|
||||
*/
|
||||
private static URI normalizeSyntax(final URI uri) {
|
||||
if (uri.isOpaque()) {
|
||||
if (uri.isOpaque() || uri.getAuthority() == null) {
|
||||
// opaque and file: URIs
|
||||
return uri;
|
||||
}
|
||||
Args.check(uri.isAbsolute(), "Base URI must be absolute");
|
||||
|
|
|
@ -173,6 +173,20 @@ public class TestURIUtils {
|
|||
"http://s/mid/content=5/../6").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveOpaque() {
|
||||
Assert.assertEquals("example://a/b/c/%7Bfoo%7D", URIUtils.resolve(this.baseURI, "eXAMPLE://a/./b/../b/%63/%7bfoo%7d").toString());
|
||||
Assert.assertEquals("file://localhost/etc/fstab", URIUtils.resolve(this.baseURI, "file://localhost/etc/fstab").toString());
|
||||
Assert.assertEquals("file:///etc/fstab", URIUtils.resolve(this.baseURI, "file:///etc/fstab").toString());
|
||||
Assert.assertEquals("file://localhost/c:/WINDOWS/clock.avi", URIUtils.resolve(this.baseURI, "file://localhost/c:/WINDOWS/clock.avi").toString());
|
||||
Assert.assertEquals("file:///c:/WINDOWS/clock.avi", URIUtils.resolve(this.baseURI, "file:///c:/WINDOWS/clock.avi").toString());
|
||||
Assert.assertEquals("file://hostname/path/to/the%20file.txt", URIUtils.resolve(this.baseURI, "file://hostname/path/to/the%20file.txt").toString());
|
||||
Assert.assertEquals("file:///c:/path/to/the%20file.txt", URIUtils.resolve(this.baseURI, "file:///c:/path/to/the%20file.txt").toString());
|
||||
Assert.assertEquals("urn:issn:1535-3613", URIUtils.resolve(this.baseURI, "urn:issn:1535-3613").toString());
|
||||
Assert.assertEquals("mailto:user@example.com", URIUtils.resolve(this.baseURI, "mailto:user@example.com").toString());
|
||||
Assert.assertEquals("ftp://example.org/resource.txt", URIUtils.resolve(this.baseURI, "ftp://example.org/resource.txt").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractHost() throws Exception {
|
||||
Assert.assertEquals(new HttpHost("localhost"),
|
||||
|
|
Loading…
Reference in New Issue