Class HttpURI
- java.lang.Object
-
- org.eclipse.jetty.http.HttpURI
-
@Deprecated(since="2021-05-27") public class HttpURI extends java.lang.Object
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.Http URI. Parse an HTTP URI from a string or byte array. Given a URIhttp://user@host:port/path;param1/%2e/info;param2?query#fragment
this class will split it into the following optional elements:getScheme()
- http:getAuthority()
- //name@host:portgetHost()
- hostgetPort()
- portgetPath()
- /path;param1/%2e/info;param2getDecodedPath()
- /path/infogetParam()
- param2getQuery()
- querygetFragment()
- fragment
The path part of the URI is provided in both raw form (
getPath()
) and decoded form (getDecodedPath()
), which has: path parameters removed, percent encoded characters expanded and relative segments resolved. This approach is somewhat contrary to RFC3986 which no longer defines path parameters (removed after RFC2396) and specifies that relative segment normalization should take place before percent encoded character expansion. A literal interpretation of the RFC can result in URI paths with ambiguities when viewed as strings. For example, a URI of/foo%2f..%2fbar
is technically a single segment of "/foo/../bar", but could easily be misinterpreted as 3 segments resolving to "/bar" by a file system.Thus this class avoid and/or detects such ambiguities. Furthermore, by decoding characters and removing parameters before relative path normalization, ambiguous paths will be resolved in such a way to be non-standard-but-non-ambiguous to down stream interpretation of the decoded path string. The violations are recorded and available by API such as
hasAmbiguousSegment()
so that requests containing them may be rejected in case the non-standard-but-non-ambiguous interpretations are not satisfactory for a given compliance configuration.Implementations that wish to process ambiguous URI paths must configure the compliance modes to accept them and then perform their own decoding of
getPath()
.If there are multiple path parameters, only the last one is returned by
getParam()
.
-
-
Constructor Summary
Constructors Constructor Description HttpURI()
Deprecated.HttpURI(java.lang.String uri)
Deprecated.HttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String pathQuery)
Deprecated.HttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.lang.String param, java.lang.String query, java.lang.String fragment)
Deprecated.HttpURI(java.net.URI uri)
Deprecated.HttpURI(HttpURI uri)
Deprecated.HttpURI(HttpURI schemeHostPort, HttpURI uri)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clear()
Deprecated.static HttpURI
createHttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.lang.String param, java.lang.String query, java.lang.String fragment)
Deprecated.Construct a normalized URI.void
decodeQueryTo(MultiMap<java.lang.String> parameters)
Deprecated.void
decodeQueryTo(MultiMap<java.lang.String> parameters, java.lang.String encoding)
Deprecated.void
decodeQueryTo(MultiMap<java.lang.String> parameters, java.nio.charset.Charset encoding)
Deprecated.boolean
equals(java.lang.Object o)
Deprecated.java.lang.String
getAuthority()
Deprecated.java.lang.String
getDecodedPath()
Deprecated.java.lang.String
getFragment()
Deprecated.java.lang.String
getHost()
Deprecated.java.lang.String
getParam()
Deprecated.Get a URI path parameter.java.lang.String
getPath()
Deprecated.The parsed Path.java.lang.String
getPathQuery()
Deprecated.int
getPort()
Deprecated.java.lang.String
getQuery()
Deprecated.java.lang.String
getScheme()
Deprecated.java.lang.String
getUser()
Deprecated.boolean
hasAmbiguousEmptySegment()
Deprecated.boolean
hasAmbiguousEncoding()
Deprecated.boolean
hasAmbiguousParameter()
Deprecated.boolean
hasAmbiguousSegment()
Deprecated.boolean
hasAmbiguousSeparator()
Deprecated.int
hashCode()
Deprecated.boolean
hasQuery()
Deprecated.boolean
hasUtf16Encoding()
Deprecated.boolean
hasViolations()
Deprecated.boolean
isAbsolute()
Deprecated.boolean
isAmbiguous()
Deprecated.void
parse(java.lang.String uri)
Deprecated.void
parse(java.lang.String uri, int offset, int length)
Deprecated.void
parseConnect(java.lang.String uri)
Deprecated.void
parseRequestTarget(java.lang.String method, java.lang.String uri)
Deprecated.Parse according to https://tools.ietf.org/html/rfc7230#section-5.3void
setAuthority(java.lang.String host, int port)
Deprecated.void
setParam(java.lang.String param)
Deprecated.void
setPath(java.lang.String path)
Deprecated.void
setPathQuery(java.lang.String pathQuery)
Deprecated.void
setQuery(java.lang.String query)
Deprecated.void
setScheme(java.lang.String scheme)
Deprecated.java.lang.String
toString()
Deprecated.java.net.URI
toURI()
Deprecated.
-
-
-
Constructor Detail
-
HttpURI
public HttpURI()
Deprecated.
-
HttpURI
public HttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.lang.String param, java.lang.String query, java.lang.String fragment)
Deprecated.
-
HttpURI
public HttpURI(HttpURI uri)
Deprecated.
-
HttpURI
public HttpURI(java.lang.String uri)
Deprecated.
-
HttpURI
public HttpURI(java.net.URI uri)
Deprecated.
-
HttpURI
public HttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String pathQuery)
Deprecated.
-
-
Method Detail
-
createHttpURI
public static HttpURI createHttpURI(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.lang.String param, java.lang.String query, java.lang.String fragment)
Deprecated.Construct a normalized URI. Port is not set if it is the default port.- Parameters:
scheme
- the URI schemehost
- the URI hoseport
- the URI portpath
- the URI pathparam
- the URI paramquery
- the URI queryfragment
- the URI fragment- Returns:
- the normalized URI
-
clear
public void clear()
Deprecated.
-
parse
public void parse(java.lang.String uri)
Deprecated.
-
parseRequestTarget
public void parseRequestTarget(java.lang.String method, java.lang.String uri)
Deprecated.Parse according to https://tools.ietf.org/html/rfc7230#section-5.3- Parameters:
method
- the request methoduri
- the request uri
-
parseConnect
@Deprecated public void parseConnect(java.lang.String uri)
Deprecated.
-
parse
public void parse(java.lang.String uri, int offset, int length)
Deprecated.
-
hasAmbiguousSegment
public boolean hasAmbiguousSegment()
Deprecated.- Returns:
- True if the URI has a possibly ambiguous segment like '..;' or '%2e%2e'
-
hasAmbiguousEmptySegment
public boolean hasAmbiguousEmptySegment()
Deprecated.- Returns:
- True if the URI empty segment that is ambiguous like '//' or '/;param/'.
-
hasAmbiguousSeparator
public boolean hasAmbiguousSeparator()
Deprecated.- Returns:
- True if the URI has a possibly ambiguous separator of %2f
-
hasAmbiguousParameter
public boolean hasAmbiguousParameter()
Deprecated.- Returns:
- True if the URI has a possibly ambiguous path parameter like '..;'
-
hasAmbiguousEncoding
public boolean hasAmbiguousEncoding()
Deprecated.- Returns:
- True if the URI has an encoded '%' character.
-
isAmbiguous
public boolean isAmbiguous()
Deprecated.- Returns:
- True if the URI has either an
hasAmbiguousSegment()
orhasAmbiguousEmptySegment()
orhasAmbiguousSeparator()
orhasAmbiguousParameter()
-
hasViolations
public boolean hasViolations()
Deprecated.- Returns:
- True if the URI has any Violations.
-
hasUtf16Encoding
public boolean hasUtf16Encoding()
Deprecated.- Returns:
- True if the URI encodes UTF-16 characters with '%u'.
-
getScheme
public java.lang.String getScheme()
Deprecated.
-
getHost
public java.lang.String getHost()
Deprecated.
-
getPort
public int getPort()
Deprecated.
-
getPath
public java.lang.String getPath()
Deprecated.The parsed Path.- Returns:
- the path as parsed on valid URI. null for invalid URI.
-
getDecodedPath
public java.lang.String getDecodedPath()
Deprecated.- Returns:
- The decoded canonical path.
- See Also:
URIUtil.canonicalPath(String)
-
getParam
public java.lang.String getParam()
Deprecated.Get a URI path parameter. Multiple and in segment parameters are ignored and only the last trailing parameter is returned.- Returns:
- The last path parameter or null
-
setParam
public void setParam(java.lang.String param)
Deprecated.
-
getQuery
public java.lang.String getQuery()
Deprecated.
-
hasQuery
public boolean hasQuery()
Deprecated.
-
getFragment
public java.lang.String getFragment()
Deprecated.
-
decodeQueryTo
public void decodeQueryTo(MultiMap<java.lang.String> parameters)
Deprecated.
-
decodeQueryTo
public void decodeQueryTo(MultiMap<java.lang.String> parameters, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Deprecated.- Throws:
java.io.UnsupportedEncodingException
-
decodeQueryTo
public void decodeQueryTo(MultiMap<java.lang.String> parameters, java.nio.charset.Charset encoding) throws java.io.UnsupportedEncodingException
Deprecated.- Throws:
java.io.UnsupportedEncodingException
-
isAbsolute
public boolean isAbsolute()
Deprecated.
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Deprecated.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Deprecated.- Overrides:
hashCode
in classjava.lang.Object
-
setScheme
public void setScheme(java.lang.String scheme)
Deprecated.
-
setAuthority
public void setAuthority(java.lang.String host, int port)
Deprecated.- Parameters:
host
- the hostport
- the port
-
setPath
public void setPath(java.lang.String path)
Deprecated.- Parameters:
path
- the path
-
setPathQuery
public void setPathQuery(java.lang.String pathQuery)
Deprecated.
-
setQuery
public void setQuery(java.lang.String query)
Deprecated.
-
toURI
public java.net.URI toURI() throws java.net.URISyntaxException
Deprecated.- Throws:
java.net.URISyntaxException
-
getPathQuery
public java.lang.String getPathQuery()
Deprecated.
-
getAuthority
public java.lang.String getAuthority()
Deprecated.
-
getUser
public java.lang.String getUser()
Deprecated.
-
-