Class ZoneIdSupport

java.lang.Object
org.apache.hc.core5.net.ZoneIdSupport

@Internal public final class ZoneIdSupport extends Object
  • Constructor Details

    • ZoneIdSupport

      private ZoneIdSupport()
  • Method Details

    • encodeZoneIdRfc6874

      public static String encodeZoneIdRfc6874(CharSequence raw)
      RFC 6874 encoder for ZoneID: emits unreserved characters as-is and percent-encodes everything else using UTF-8 with UPPERCASE hex digits. Existing %HH triplets are passed through unchanged.
    • decodeZoneId

      public static String decodeZoneId(CharSequence host)
      RFC 6874 decoder for bracket contents of an IPv6 literal. Input: "addr%25<enc-zone>" → Output internal form: "addr%<decoded-zone>". If there is no "%25" delimiter, returns the input as-is.
    • validateZoneIdEncoded

      public static void validateZoneIdEncoded(CharSequence enc)
      RFC 6874 ZoneID validator:
      ZoneID = 1*( unreserved / pct-encoded )
      Throws IllegalArgumentException on invalid input.
    • looksLikeIPv6AddressPart

      public static boolean looksLikeIPv6AddressPart(CharSequence host)
      Heuristic: returns true if host looks like an IPv6 address-part (i.e., before any ZoneID) by counting colons. We do not parse/validate IPv6; this keeps our surface minimal while still bracketing correctly.

      Rule: if the address-part (up to '%', if present) contains >= 2 colons, treat it as IPv6-like.

    • appendBracketedIPv6

      public static boolean appendBracketedIPv6(StringBuilder buf, CharSequence host)
      Appends a bracketed IPv6 literal to buf if host looks like IPv6. If a ZoneID is present (after '%'), it is written as "%25" followed by the RFC 6874-encoded ZoneID. Returns true iff it wrote the bracketed literal.
    • unreserved

      private static boolean unreserved(char ch)
      RFC 3986 unreserved characters.