类 OkHttpTransport

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

public class OkHttpTransport extends Object implements HttpTransport
OkHttp implementation of the HttpTransport interface.

This implementation uses OkHttp for HTTP communication and supports:

  • Synchronous HTTP requests
  • Server-Sent Events (SSE) streaming
  • Connection pooling
  • Configurable timeouts
  • 构造器详细资料

    • OkHttpTransport

      public OkHttpTransport()
      Create a new OkHttpTransport with default configuration.
    • OkHttpTransport

      public OkHttpTransport(HttpTransportConfig config)
      Create a new OkHttpTransport with custom configuration.
      参数:
      config - the transport configuration
    • OkHttpTransport

      public OkHttpTransport(okhttp3.OkHttpClient client, HttpTransportConfig config)
      Create a new OkHttpTransport with an existing OkHttpClient.

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

      参数:
      client - the OkHttpClient to use
      config - the transport configuration (used for reference only)
  • 方法详细资料

    • 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
    • getClient

      public okhttp3.OkHttpClient getClient()
      Get the underlying OkHttpClient instance.

      This can be useful for advanced configuration or debugging.

      返回:
      the OkHttpClient
    • getConfig

      public HttpTransportConfig getConfig()
      Get the transport configuration.
      返回:
      the configuration
    • builder

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