类 JdkHttpTransport

java.lang.Object
io.agentscope.core.model.transport.JdkHttpTransport
所有已实现的接口:
HttpTransport

public class JdkHttpTransport extends Object implements HttpTransport
Pure JDK implementation of the HttpTransport interface.

This implementation uses JDK's built-in HttpClient (java.net.http.HttpClient) for HTTP communication and supports:

  • Synchronous HTTP requests
  • Server-Sent Events (SSE) streaming
  • HTTP/2 with fallback to HTTP/1.1
  • Connection pooling (built-in)
  • Configurable timeouts

This implementation has no external dependencies beyond the JDK.

  • 构造器详细资料

    • JdkHttpTransport

      public JdkHttpTransport(HttpClient client, HttpTransportConfig config)
      Create a new JdkHttpTransport with an existing HttpClient.

      Use this constructor when you want to share an HttpClient instance across multiple components.

      参数:
      client - the HttpClient to use
      config - the transport configuration (used for reference only)
      抛出:
      NullPointerException - if client or config is null
  • 方法详细资料

    • execute

      public HttpResponse execute(HttpRequest request) throws HttpTransportException
      从接口复制的说明: HttpTransport
      Execute a synchronous HTTP request.
      指定者:
      execute 在接口中 HttpTransport
      参数:
      request - the HTTP request to execute
      返回:
      the HTTP response
      抛出:
      HttpTransportException - if the request fails
    • stream

      public reactor.core.publisher.Flux<String> stream(HttpRequest request)
      从接口复制的说明: HttpTransport
      Execute a streaming HTTP request (Server-Sent Events).

      This method returns a Flux that emits each SSE data line as a String. The implementation should handle parsing the SSE format and extracting the data content from each event.

      指定者:
      stream 在接口中 HttpTransport
      参数:
      request - the HTTP request to execute
      返回:
      a Flux emitting SSE data lines as strings
    • close

      public void close()
      从接口复制的说明: HttpTransport
      Close the transport and release any resources.

      After calling this method, the transport should not be used.

      指定者:
      close 在接口中 HttpTransport
    • isClosed

      public boolean isClosed()
      Check if this transport has been closed.
      返回:
      true if closed
    • builder

      public static JdkHttpTransport.Builder builder()
      Create a new builder for JdkHttpTransport.
      返回:
      a new Builder instance