Package org.eclipse.jetty.http
Class HttpURI
java.lang.Object
org.eclipse.jetty.http.HttpURI
Http URI.
Parse an HTTP URI from a string or byte array. Given a URI
http://user@host:port/path/info;param?query#fragment
this class will split it into the following undecoded optional elements:getScheme()
- http:getAuthority()
- //name@host:portgetHost()
- hostgetPort()
- portgetPath()
- /path/infogetParam()
- paramgetQuery()
- querygetFragment()
- fragment
Any parameters will be returned from getPath()
, but are excluded from the
return value of getDecodedPath()
. If there are multiple parameters, the
getParam()
method returns only the last one.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
private static enum
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkSegment
(String uri, int segment, int end, boolean param) Check for ambiguous path segments.void
clear()
static HttpURI
createHttpURI
(String scheme, String host, int port, String path, String param, String query, String fragment) Construct a normalized URI.void
decodeQueryTo
(MultiMap<String> parameters) void
decodeQueryTo
(MultiMap<String> parameters, String encoding) void
decodeQueryTo
(MultiMap<String> parameters, Charset encoding) boolean
getHost()
getParam()
getPath()
The parsed Path.int
getPort()
getQuery()
getUser()
boolean
boolean
boolean
int
hashCode()
boolean
hasQuery()
boolean
boolean
void
void
private void
parse
(HttpURI.State state, String uri, int offset, int end) void
parseConnect
(String uri) Deprecated.void
parseRequestTarget
(String method, String uri) Parse according to https://tools.ietf.org/html/rfc7230#section-5.3void
setAuthority
(String host, int port) void
void
void
setPathQuery
(String pathQuery) void
void
toString()
toURI()
-
Field Details
-
__ambiguousSegments
The concept of URI path parameters was originally specified in RFC2396, but that was obsoleted by RFC3986 which removed a normative definition of path parameters. Specifically it excluded them from the Remove Dot Segments algorithm. This results in some ambiguity as dot segments can result from later parameter removal or % encoding expansion, that are not removed from the URI byURIUtil.canonicalPath(String)
. Thus this class flags such ambiguous path segments, so that they may be rejected by the server if so configured. -
_scheme
-
_user
-
_host
-
_port
private int _port -
_path
-
_param
-
_query
-
_fragment
-
_uri
-
_decodedPath
-
_ambiguous
-
-
Constructor Details
-
HttpURI
public HttpURI() -
HttpURI
-
HttpURI
-
HttpURI
-
HttpURI
-
HttpURI
-
-
Method Details
-
createHttpURI
public static HttpURI createHttpURI(String scheme, String host, int port, String path, String param, String query, String fragment) 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() -
parse
-
parseRequestTarget
Parse according to https://tools.ietf.org/html/rfc7230#section-5.3- Parameters:
method
- the request methoduri
- the request uri
-
parseConnect
Deprecated. -
parse
-
parse
-
checkSegment
Check for ambiguous path segments. An ambiguous path segment is one that is perhaps technically legal, but is considered undesirable to handle due to possible ambiguity. Examples include segments like '..;', '%2e', '%2e%2e' etc.- Parameters:
uri
- The URI stringsegment
- The inclusive starting index of the segment (excluding any '/')end
- The exclusive end index of the segment
-
hasAmbiguousSegment
public boolean hasAmbiguousSegment()- Returns:
- True if the URI has a possibly ambiguous segment like '..;' or '%2e%2e'
-
hasAmbiguousSeparator
public boolean hasAmbiguousSeparator()- Returns:
- True if the URI has a possibly ambiguous separator of %2f
-
hasAmbiguousParameter
public boolean hasAmbiguousParameter()- Returns:
- True if the URI has a possibly ambiguous path parameter like '..;'
-
isAmbiguous
public boolean isAmbiguous()- Returns:
- True if the URI has either an
hasAmbiguousSegment()
orhasAmbiguousSeparator()
.
-
getScheme
-
getHost
-
getPort
public int getPort() -
getPath
The parsed Path.- Returns:
- the path as parsed on valid URI. null for invalid URI.
-
getDecodedPath
- Returns:
- The decoded canonical path.
- See Also:
-
getParam
-
setParam
-
getQuery
-
hasQuery
public boolean hasQuery() -
getFragment
-
decodeQueryTo
-
decodeQueryTo
public void decodeQueryTo(MultiMap<String> parameters, String encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
decodeQueryTo
public void decodeQueryTo(MultiMap<String> parameters, Charset encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
isAbsolute
public boolean isAbsolute() -
toString
-
equals
-
hashCode
public int hashCode() -
setScheme
-
setAuthority
- Parameters:
host
- the hostport
- the port
-
setPath
- Parameters:
path
- the path
-
setPathQuery
-
setQuery
-
toURI
- Throws:
URISyntaxException
-
getPathQuery
-
getAuthority
-
getUser
-