Interface A2AHttpClient.PostBuilder

All Superinterfaces:
A2AHttpClient.Builder<A2AHttpClient.PostBuilder>
Enclosing interface:
A2AHttpClient

public static interface A2AHttpClient.PostBuilder extends A2AHttpClient.Builder<A2AHttpClient.PostBuilder>
Builder for HTTP POST requests.

Supports both synchronous requests and asynchronous Server-Sent Events (SSE) streaming.

  • Method Details

    • body

      Sets the request body content.
      Parameters:
      body - the request body string (typically JSON)
      Returns:
      this builder for chaining
    • followRedirects

      default A2AHttpClient.PostBuilder followRedirects(boolean follow)
      Controls whether the HTTP client follows redirects for this request. When set to false, redirect responses (3xx) are returned as-is instead of being followed automatically.

      Security-sensitive code (e.g. push notification delivery) should disable redirects to prevent SSRF bypass via open redirectors.

      Note for implementors: The default implementation is a no-op that silently ignores the follow argument. Third-party A2AHttpClient implementations MUST override this method to honour the setting; otherwise followRedirects(false) calls have no effect and redirects will still be followed, bypassing SSRF protection.

      Parameters:
      follow - true to follow redirects (default), false to disable
      Returns:
      this builder for chaining
    • post

      Executes a synchronous POST request.
      Returns:
      the HTTP response
      Throws:
      IOException - if an I/O error occurs
      InterruptedException - if the operation is interrupted
    • postAsyncSSE

      CompletableFuture<Void> postAsyncSSE(Consumer<ServerSentEvent> messageConsumer, Consumer<Throwable> errorConsumer, Runnable completeRunnable) throws IOException, InterruptedException
      Executes an asynchronous POST request expecting Server-Sent Events (SSE).

      The request will stream SSE messages asynchronously, invoking the provided consumers for each event, error, or completion.

      Parameters:
      messageConsumer - callback for each SSE message received
      errorConsumer - callback for errors during streaming
      completeRunnable - callback when the stream completes normally
      Returns:
      a CompletableFuture that completes when streaming ends
      Throws:
      IOException - if an I/O error occurs
      InterruptedException - if the operation is interrupted