Class HttpURI


  • @Deprecated(since="2021-05-27")
    public class HttpURI
    extends 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 URI http://user@host:port/path;param1/%2e/info;param2?query#fragment this class will split it into the following optional elements:

    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 Detail

      • HttpURI

        public HttpURI()
        Deprecated.
      • HttpURI

        public HttpURI​(HttpURI uri)
        Deprecated.
      • HttpURI

        public HttpURI​(HttpURI schemeHostPort,
                       HttpURI uri)
        Deprecated.
      • HttpURI

        public HttpURI​(String uri)
        Deprecated.
      • HttpURI

        public HttpURI​(URI uri)
        Deprecated.
      • HttpURI

        public HttpURI​(String scheme,
                       String host,
                       int port,
                       String pathQuery)
        Deprecated.
    • Method Detail

      • createHttpURI

        public static HttpURI createHttpURI​(String scheme,
                                            String host,
                                            int port,
                                            String path,
                                            String param,
                                            String query,
                                            String fragment)
        Deprecated.
        Construct a normalized URI. Port is not set if it is the default port.
        Parameters:
        scheme - the URI scheme
        host - the URI hose
        port - the URI port
        path - the URI path
        param - the URI param
        query - the URI query
        fragment - the URI fragment
        Returns:
        the normalized URI
      • clear

        public void clear()
        Deprecated.
      • parse

        public void parse​(String uri)
        Deprecated.
      • parseRequestTarget

        public void parseRequestTarget​(String method,
                                       String uri)
        Deprecated.
        Parse according to https://tools.ietf.org/html/rfc7230#section-5.3
        Parameters:
        method - the request method
        uri - the request uri
      • parse

        public void parse​(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.
      • 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 String getScheme()
        Deprecated.
      • getHost

        public String getHost()
        Deprecated.
      • getPort

        public int getPort()
        Deprecated.
      • getPath

        public String getPath()
        Deprecated.
        The parsed Path.
        Returns:
        the path as parsed on valid URI. null for invalid URI.
      • getParam

        public 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​(String param)
        Deprecated.
      • getQuery

        public String getQuery()
        Deprecated.
      • hasQuery

        public boolean hasQuery()
        Deprecated.
      • getFragment

        public String getFragment()
        Deprecated.
      • decodeQueryTo

        public void decodeQueryTo​(MultiMap<String> parameters)
        Deprecated.
      • isAbsolute

        public boolean isAbsolute()
        Deprecated.
      • equals

        public boolean equals​(Object o)
        Deprecated.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Deprecated.
        Overrides:
        hashCode in class Object
      • setScheme

        public void setScheme​(String scheme)
        Deprecated.
      • setAuthority

        public void setAuthority​(String host,
                                 int port)
        Deprecated.
        Parameters:
        host - the host
        port - the port
      • setPath

        public void setPath​(String path)
        Deprecated.
        Parameters:
        path - the path
      • setPathQuery

        public void setPathQuery​(String pathQuery)
        Deprecated.
      • setQuery

        public void setQuery​(String query)
        Deprecated.
      • getPathQuery

        public String getPathQuery()
        Deprecated.
      • getAuthority

        public String getAuthority()
        Deprecated.
      • getUser

        public String getUser()
        Deprecated.