Class JdkA2AHttpClient
- All Implemented Interfaces:
A2AHttpClient
HttpClient.
This is the fallback implementation used when no higher-priority
A2AHttpClientProvider is available. It provides full support for:
- HTTP/2 with automatic fallback to HTTP/1.1
- Synchronous GET, POST, and DELETE requests
- Asynchronous Server-Sent Events (SSE) streaming
Security Note: The default client does not follow HTTP redirects
automatically to prevent credential leakage to third-party origins. If redirect
following is required, provide a custom HttpClient via the constructor
JdkA2AHttpClient(HttpClient).
Provider Priority: 0 (lowest - used as fallback)
This implementation is registered via JdkA2AHttpClientProvider
in the ServiceLoader system and is automatically used by A2AHttpClientFactory
when no other provider is available.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.a2aproject.sdk.client.http.A2AHttpClient
A2AHttpClient.Builder<T extends A2AHttpClient.Builder<T>>, A2AHttpClient.DeleteBuilder, A2AHttpClient.GetBuilder, A2AHttpClient.PostBuilder -
Field Summary
Fields inherited from interface org.a2aproject.sdk.client.http.A2AHttpClient
ACCEPT, APPLICATION_JSON, CONTENT_TYPE, EVENT_STREAM -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new JDK-based HTTP client with secure defaults.JdkA2AHttpClient(HttpClient httpClient) Creates a new JDK-based HTTP client using a caller-provided JDKHttpClient. -
Method Summary
Modifier and TypeMethodDescriptionCreates a builder for DELETE requests.Creates a builder for GET requests.Creates a builder for POST requests.
-
Constructor Details
-
JdkA2AHttpClient
public JdkA2AHttpClient()Creates a new JDK-based HTTP client with secure defaults.Configures the client with:
- HTTP/2 preferred (with HTTP/1.1 fallback)
- No automatic redirect following (security hardening to prevent credential leakage)
If redirect following is required, use
JdkA2AHttpClient(HttpClient)with a customHttpClientconfigured appropriately. -
JdkA2AHttpClient
Creates a new JDK-based HTTP client using a caller-provided JDKHttpClient.This constructor allows full control over the
HttpClientconfiguration, including redirect policy. The caller is responsible for ensuring the client is configured securely.- Parameters:
httpClient- the JDK HTTP client to delegate requests to- Throws:
IllegalArgumentException- ifhttpClientisnull
-
-
Method Details
-
createGet
Description copied from interface:A2AHttpClientCreates a builder for GET requests.- Specified by:
createGetin interfaceA2AHttpClient- Returns:
- a new GetBuilder instance
-
createPost
Description copied from interface:A2AHttpClientCreates a builder for POST requests.- Specified by:
createPostin interfaceA2AHttpClient- Returns:
- a new PostBuilder instance
-
createDelete
Description copied from interface:A2AHttpClientCreates a builder for DELETE requests.- Specified by:
createDeletein interfaceA2AHttpClient- Returns:
- a new DeleteBuilder instance
-