Package org.a2aproject.sdk.client.http
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final A2AHttpHeadersEmpty headers instance returned by default when headers are not available. -
Method Summary
Modifier and TypeMethodDescriptionReturns all values for the given header name.@Nullable StringfirstValue(String name) Returns the first value for the given header name, ornullif not present.static A2AHttpHeadersCreates anA2AHttpHeadersinstance from a map of header name to value lists.toMap()Returns an unmodifiable map of all headers.
-
Field Details
-
EMPTY
Empty headers instance returned by default when headers are not available.
-
-
Method Details
-
firstValue
Returns the first value for the given header name, ornullif not present.- Parameters:
name- the header name (case-insensitive)- Returns:
- the first header value, or
null
-
allValues
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
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
Creates anA2AHttpHeadersinstance 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
nullstatus-line key fromHttpURLConnection).- Parameters:
headers- the source header map; may be null-keyed- Returns:
- an immutable, case-insensitive
A2AHttpHeadersview
-