JdkHttpTransport
public class JdkHttpTransport implements HttpTransport
io/agentscope/core/model/transport/JdkHttpTransport.java:70–649Jdk HTTP 传输层,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.model.transport 包,实现 HttpTransport。核心成员包括 execute、stream、close、isClosed、builder、JdkHttpTransport。
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.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | JdkHttpTransport的构建器。 Builder for JdkHttpTransport. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public JdkHttpTransport(HttpClient client, HttpTransportConfig config) | 初始化 `JdkHttpTransport` 实例。 Create a new JdkHttpTransport with an existing HttpClient. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public HttpResponse execute(HttpRequest request) throws HttpTransportException | 设置执行。 Performs the execute operation. |
public Flux<String> stream(HttpRequest request) | 设置流。 Performs the stream operation. |
public void close() | 关闭连接并释放相关资源。 Releases resources and connections. |
public boolean isClosed() | 判断是否已关闭。 Check if this transport has been closed. |
public static Builder builder()static | 创建用于JdkHttpTransport的构建器。 Create a new builder for JdkHttpTransport. |
构造器详情Constructor Detail
JdkHttpTransport
public JdkHttpTransport(HttpClient client, HttpTransportConfig config)
初始化 JdkHttpTransport 实例。
Create a new JdkHttpTransport with an existing HttpClient.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | HttpClient | HttpClient 到使用。the HttpClient to use |
config | HttpTransportConfig | 配置对象(类型 `HttpTransportConfig`)。the transport configuration (used for reference only) |
NullPointerException可能抛出 `NullPointerException`。if client or config is null
io/agentscope/core/model/transport/JdkHttpTransport.java:108–111方法详情Method Detail
execute
public HttpResponse execute(HttpRequest request) throws HttpTransportException
设置执行。
Performs the execute operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | HttpRequest | 请求(类型 `HttpRequest`)。The request. |
HttpResponseHttpTransportException可能抛出 `HttpTransportException`。Thrown when the operation cannot be completed.
io/agentscope/core/model/transport/JdkHttpTransport.java:179–196stream
public Flux<String> stream(HttpRequest request)
设置流。
Performs the stream operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | HttpRequest | 请求(类型 `HttpRequest`)。The request. |
Flux<String>io/agentscope/core/model/transport/JdkHttpTransport.java:198–222close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/core/model/transport/JdkHttpTransport.java:348–352isClosed
public boolean isClosed()
判断是否已关闭。
Check if this transport has been closed.
booleanio/agentscope/core/model/transport/JdkHttpTransport.java:379–381builder
public static Builder builder()
创建用于JdkHttpTransport的构建器。
Create a new builder for JdkHttpTransport.
Builderio/agentscope/core/model/transport/JdkHttpTransport.java:549–551嵌套类详情Nested Class Detail
Builder
public static class BuilderJdkHttpTransport的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 config、client、build。
Builder for JdkHttpTransport.