Class UriUtils


  • public final class UriUtils
    extends Object
    URI convenience methods.
    • Method Detail

      • isSecure

        public static boolean isSecure​(String scheme)
        Returns true if the given URI scheme is for a secure (TLS) connection.
        Parameters:
        scheme - URI scheme
        Returns:
        true if the given URI scheme is for a secure (TLS) connection.
      • getNonEmptyPath

        public static String getNonEmptyPath​(MutableUri uri)
        Returns / when the given uri has no path component, returns the uri path otherwise.

        Convenient for HTTP layer when targeting server root

        Parameters:
        uri - request's uri
        Returns:
        the raw path or "/" if it's null
      • getPort

        public static int getPort​(String scheme,
                                  int port)
        Returns the default's protocol port if not set in the given URI scheme, the URI port otherwise.
        Parameters:
        scheme - URI scheme
        port - port as returned by the URI (can be -1 if unset)
        Returns:
        the default's protocol port if not set in the given URI scheme, the URI port otherwise.