Class GrpcUtil.AuthorityEscaper

  • Enclosing class:
    GrpcUtil

    public static class GrpcUtil.AuthorityEscaper
    extends java.lang.Object
    Percent encode the authority based on https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.

    When escaping a String, the following rules apply:

    • The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
    • The unreserved characters ".", "-", "~", and "_" remain the same.
    • The general delimiters for authority, "[", "]", "@" and ":" remain the same.
    • The subdelimiters "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", and "=" remain the same.
    • The space character " " is converted into %20.
    • All other characters are converted into one or more bytes using UTF-8 encoding and each byte is then represented by the 3-character string "%XY", where "XY" is the two-digit, uppercase, hexadecimal representation of the byte value.

    This section does not use URLEscapers from Guava Net as its not Android-friendly thus core can't depend on it.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String encodeAuthority​(java.lang.String authority)  
      private static boolean shouldEscape​(char c)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UPPER_HEX_DIGITS

        private static final char[] UPPER_HEX_DIGITS
      • UNRESERVED_CHARACTERS

        private static final java.util.Set<java.lang.Character> UNRESERVED_CHARACTERS
      • SUB_DELIMS

        private static final java.util.Set<java.lang.Character> SUB_DELIMS
      • AUTHORITY_DELIMS

        private static final java.util.Set<java.lang.Character> AUTHORITY_DELIMS
    • Constructor Detail

      • AuthorityEscaper

        public AuthorityEscaper()
    • Method Detail

      • shouldEscape

        private static boolean shouldEscape​(char c)
      • encodeAuthority

        public static java.lang.String encodeAuthority​(java.lang.String authority)