Top Description Inners Methods
org.eclipse.jetty.http

public Interface HttpURI

Known Direct Implementers
org.eclipse.jetty.http.HttpURI.Immutable, org.eclipse.jetty.http.HttpURI.Mutable
Imports
java.io.Serial, .Serializable, java.net.URI, .URISyntaxException, java.util.Collection, .Collections, .EnumSet, .Set, org.eclipse.jetty.http.UriCompliance.Violation, org.eclipse.jetty.util.HostPort, .Index, .StringUtil, .TypeUtil, .URIUtil, .UrlEncoded

Http URI. Both Mutable and Immutable implementations are available via the static methods such as build() and from(String). A URI such as http://user@host:port/path;param1/%2e/f%6fo%2fbar%20bob;param2?query#fragment is split into the following optional elements:

The path part of the URI is provided in both raw form (getPath()) and decoded form (getCanonicalPath), 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().

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Method Summary

Modifier and TypeMethod and Description
public HttpURI.Immutable
public String
public static HttpURI.Mutable
public static HttpURI.Mutable
public static HttpURI.Mutable
build(HttpURI uri, String pathQuery)

public static HttpURI.Mutable
build(HttpURI uri, String path, String param, String query)

public static HttpURI.Mutable
build(URI uri)

public static HttpURI.Mutable
public static HttpURI.Mutable
build(String method, String uri)

public static HttpURI.Immutable
from(URI uri)

public static HttpURI.Immutable
from(String uri)

public static HttpURI.Immutable
from(String method, String uri)

public static HttpURI.Immutable
from(String scheme, HostPort hostPort, String pathQuery)

public static HttpURI.Immutable
from(String scheme, String host, int port, String pathQuery)

public String
public String
public String
public String
public String
public String

Returns:

The last path parameter or null
getParam
()

Get a URI path parameter.

public String
public String
public int
public String
public String
public String
public Collection<UriCompliance.Violation>

Returns:

Set of violations in the URI.
getViolations
()

public default boolean

Returns:

True if the URI empty segment that is ambiguous like '//' or '/;param/'.
hasAmbiguousEmptySegment
()

public default boolean

Returns:

True if the URI has an encoded '%' character.
hasAmbiguousEncoding
()

public default boolean

Returns:

True if the URI has a possibly ambiguous path parameter like '..;'
hasAmbiguousParameter
()

public default boolean

Returns:

True if the URI has a possibly ambiguous segment like '..;' or '%2e%2e'
hasAmbiguousSegment
()

public default boolean

Returns:

True if the URI has a possibly ambiguous separator of %2f
hasAmbiguousSeparator
()

public boolean
public default boolean

Returns:

True if the URI has UTF16 '%u' encodings.
hasUtf16Encoding
()

public boolean

Returns:

true if the URI has the passed violation.
hasViolation
(UriCompliance.Violation
the violation to check.
violation
)

public boolean

Returns:

True if the URI has any Violations.
hasViolations
()

public boolean
public boolean

Returns:

True if the URI has any ambiguous Violations.
isAmbiguous
()

public default URI