Class HttpURI


  • public class HttpURI
    extends java.lang.Object
    Http URI. Parse a 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:

    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.

    • Constructor Summary

      Constructors 
      Constructor Description
      HttpURI()  
      HttpURI​(java.lang.String uri)  
      HttpURI​(java.lang.String scheme, java.lang.String host, int port, java.lang.String pathQuery)  
      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)  
      HttpURI​(java.net.URI uri)  
      HttpURI​(HttpURI uri)  
    • Constructor Detail

      • HttpURI

        public HttpURI()
      • 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)
      • HttpURI

        public HttpURI​(HttpURI uri)
      • HttpURI

        public HttpURI​(java.lang.String uri)
      • HttpURI

        public HttpURI​(java.net.URI uri)
      • HttpURI

        public HttpURI​(java.lang.String scheme,
                       java.lang.String host,
                       int port,
                       java.lang.String pathQuery)
    • 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)
        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
      • parse

        public void parse​(java.lang.String uri)
      • parseRequestTarget

        public void parseRequestTarget​(java.lang.String method,
                                       java.lang.String uri)
        Parse according to https://tools.ietf.org/html/rfc7230#section-5.3
        Parameters:
        method - the request method
        uri - 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)
      • getScheme

        public java.lang.String getScheme()
      • getHost

        public java.lang.String getHost()
      • getPort

        public int getPort()
      • getPath

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

        public java.lang.String getDecodedPath()
      • getParam

        public java.lang.String getParam()
      • getQuery

        public java.lang.String getQuery()
      • hasQuery

        public boolean hasQuery()
      • getFragment

        public java.lang.String getFragment()
      • decodeQueryTo

        public void decodeQueryTo​(MultiMap<java.lang.String> parameters)
      • decodeQueryTo

        public void decodeQueryTo​(MultiMap<java.lang.String> parameters,
                                  java.lang.String encoding)
                           throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • decodeQueryTo

        public void decodeQueryTo​(MultiMap<java.lang.String> parameters,
                                  java.nio.charset.Charset encoding)
                           throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • clear

        public void clear()
      • isAbsolute

        public boolean isAbsolute()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • setScheme

        public void setScheme​(java.lang.String scheme)
      • setAuthority

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

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

        public void setPathQuery​(java.lang.String path)
      • setQuery

        public void setQuery​(java.lang.String query)
      • toURI

        public java.net.URI toURI()
                           throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
      • getPathQuery

        public java.lang.String getPathQuery()
      • getAuthority

        public java.lang.String getAuthority()
      • getUser

        public java.lang.String getUser()