Class JdkA2AHttpClient

java.lang.Object
org.a2aproject.sdk.client.http.JdkA2AHttpClient
All Implemented Interfaces:
A2AHttpClient

public class JdkA2AHttpClient extends Object implements A2AHttpClient
Default HTTP client implementation using JDK 11+ 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.

See Also:
  • 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 custom HttpClient configured appropriately.

    • JdkA2AHttpClient

      public JdkA2AHttpClient(HttpClient httpClient)
      Creates a new JDK-based HTTP client using a caller-provided JDK HttpClient.

      This constructor allows full control over the HttpClient configuration, 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 - if httpClient is null
  • Method Details