Interface A2AHttpHeaders


public interface A2AHttpHeaders
Read-only abstraction over HTTP response headers.

Header names are case-insensitive per RFC 7230. Implementations must perform case-insensitive lookup for all accessor methods.

HTTP headers may have multiple values for the same name (e.g. Set-Cookie). Use allValues(String) to retrieve all values, or firstValue(String) when only a single value is expected (e.g. Retry-After, Content-Type).

Usage Example


 A2AHttpResponse response = client.createPost()
     .url("http://localhost:9999/message:send")
     .body(jsonBody)
     .post();

 if (!response.success()) {
     String retryAfter = response.headers().firstValue("Retry-After");
     // Handle rate limiting
 }
 
See Also:
  • Field Details

    • EMPTY

      static final A2AHttpHeaders EMPTY
      Empty headers instance returned by default when headers are not available.
  • Method Details

    • firstValue

      @Nullable String firstValue(String name)
      Returns the first value for the given header name, or null if not present.
      Parameters:
      name - the header name (case-insensitive)
      Returns:
      the first header value, or null
    • allValues

      List<String> allValues(String name)
      Returns all values for the given header name.
      Parameters:
      name - the header name (case-insensitive)
      Returns:
      an unmodifiable list of values, empty if the header is not present
    • toMap

      Map<String,List<String>> toMap()
      Returns an unmodifiable map of all headers.

      The keys in the returned map are in their original casing from the response.

      Returns:
      map of header names to lists of values
    • of

      static A2AHttpHeaders of(Map<String,List<String>> headers)
      Creates an A2AHttpHeaders instance from a map of header name to value lists.

      Builds a case-insensitive snapshot: null keys and null value lists are silently skipped (e.g. the null status-line key from HttpURLConnection).

      Parameters:
      headers - the source header map; may be null-keyed
      Returns:
      an immutable, case-insensitive A2AHttpHeaders view