Package org.apache.hc.client5.http.utils
Class URIUtils
java.lang.Object
org.apache.hc.client5.http.utils.URIUtils
A collection of utilities for
URIs
, to workaround
bugs within the class or for ease-of-use features.- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic URI
Deprecated.static URI
Deprecated.UseURIBuilder
.static org.apache.hc.core5.http.HttpHost
extractHost
(URI uri) Extracts target host from the givenURI
.(package private) static URI
normalizeSyntax
(URI uri) Removes dot segments and performs Syntax-Based Normalization.static URI
Resolves a URI reference against a base URI.static URI
Resolves a URI reference against a base URI.static URI
Derives the interpreted (absolute) URI that was used to generate the last request.static URI
rewriteURI
(URI uri) Deprecated.UseURIBuilder
.static URI
rewriteURI
(URI uri, org.apache.hc.core5.http.HttpHost target) Deprecated.UseURIBuilder
.static URI
rewriteURI
(URI uri, org.apache.hc.core5.http.HttpHost target, boolean dropFragment) Deprecated.UseURIBuilder
.
-
Constructor Details
-
URIUtils
private URIUtils()This class should not be instantiated.
-
-
Method Details
-
rewriteURI
@Deprecated public static URI rewriteURI(URI uri, org.apache.hc.core5.http.HttpHost target, boolean dropFragment) throws URISyntaxException Deprecated.UseURIBuilder
.A convenience method for creating a newURI
whose scheme, host and port are taken from the target host, but whose path, query and fragment are taken from the existing URI. The fragment is only used if dropFragment is false. The path is set to "/" if not explicitly specified.- Parameters:
uri
- Contains the path, query and fragment to use.target
- Contains the scheme, host and port to use.dropFragment
- True if the fragment should not be copied.- Throws:
URISyntaxException
- If the resulting URI is invalid.
-
rewriteURI
@Deprecated public static URI rewriteURI(URI uri, org.apache.hc.core5.http.HttpHost target) throws URISyntaxException Deprecated.UseURIBuilder
.A convenience method forrewriteURI(URI, HttpHost, boolean)
that always keeps the fragment.- Throws:
URISyntaxException
-
rewriteURI
Deprecated.UseURIBuilder
.A convenience method that creates a newURI
whose scheme, host, port, path, query are taken from the existing URI, dropping any fragment or user-information. The path is set to "/" if not explicitly specified. The existing URI is returned unmodified if it has no fragment or user-information and has a path.- Parameters:
uri
- original URI.- Throws:
URISyntaxException
- If the resulting URI is invalid.
-
resolve
Resolves a URI reference against a base URI. Work-around for bug in java.net.URI (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535)- Parameters:
baseURI
- the base URIreference
- the URI reference- Returns:
- the resulting URI
-
resolve
Resolves a URI reference against a base URI. Work-around for bugs in java.net.URI (e.g. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535)- Parameters:
baseURI
- the base URIreference
- the URI reference- Returns:
- the resulting URI
-
normalizeSyntax
Removes dot segments and performs Syntax-Based Normalization.- Parameters:
uri
- the original URI- Returns:
- the URI without dot segments
- Throws:
URISyntaxException
-
extractHost
Extracts target host from the givenURI
.- Parameters:
uri
-- Returns:
- the target host if the URI is absolute or
null
if the URI is relative or does not contain a valid host name. - Since:
- 4.1
-
resolve
public static URI resolve(URI originalURI, org.apache.hc.core5.http.HttpHost target, List<URI> redirects) throws URISyntaxException Derives the interpreted (absolute) URI that was used to generate the last request. This is done by extracting the request-uri and target origin for the last request and scanning all the redirect locations for the last fragment identifier, then combining the result into aURI
.- Parameters:
originalURI
- original request before any redirectstarget
- if the last URI is relative, it is resolved against this target, ornull
if not available.redirects
- collection of redirect locations since the original request ornull
if not available.- Returns:
- interpreted (absolute) URI
- Throws:
URISyntaxException
-
create
@Deprecated public static URI create(org.apache.hc.core5.http.HttpHost host, String path) throws URISyntaxException Deprecated.UseURIBuilder
.Convenience factory method forURI
instances.- Throws:
URISyntaxException
- Since:
- 5.0
-
create
@Deprecated public static URI create(String scheme, org.apache.hc.core5.net.URIAuthority host, String path) throws URISyntaxException Deprecated.UseURIBuilder
.Convenience factory method forURI
instances.- Throws:
URISyntaxException
- Since:
- 5.0
-
URIBuilder
.