Class HttpAuthHeaders

java.lang.Object
org.apache.pulsar.client.api.v5.auth.HttpAuthHeaders

public final class HttpAuthHeaders extends Object
HTTP authentication headers an implementation produces for an outgoing request (and, for challenge/response, the headers carrying a server's challenge) (PIP-478).

Header names are canonicalised on construction (RFC 7230 ยง3.2 treats them case-insensitively); get(String) is case-insensitive; asMap() returns a stable canonical-cased view.

Single value per name. This collapses to one value per canonical name: when the source map passed to of(Map) holds two entries that canonicalise to the same name (case-variants such as Authorization and authorization), the one visited last in the source map's iteration order wins. Multi-valued headers are not represented.

  • Method Details

    • empty

      public static HttpAuthHeaders empty()
      Returns:
      a shared empty instance
    • of

      public static HttpAuthHeaders of(String name, String value)
      Create headers with a single entry.
      Parameters:
      name - the header name
      value - the header value
      Returns:
      a new HttpAuthHeaders
    • of

      public static HttpAuthHeaders of(Map<String,String> headers)
      Create headers from a map. Names are canonicalised; two source entries that canonicalise to the same name (case-variants) collapse to one, and the entry visited last in headers' iteration order wins.
      Parameters:
      headers - the source headers (names canonicalised)
      Returns:
      a new HttpAuthHeaders
    • get

      public Optional<String> get(String name)
      Look up a header value, case-insensitively.
      Parameters:
      name - the header name
      Returns:
      the header value if present
    • asMap

      public Map<String,String> asMap()
      Returns:
      an unmodifiable, canonical-cased view of the headers
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if there are no headers
    • toString

      public String toString()
      Overrides:
      toString in class Object