AS AgentScopeAPI 手册 / API Reference

CompressingOkHttpTransport

public class CompressingOkHttpTransport implements HttpTransport
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:69–499

Compressing Ok HTTP 传输层,为框架提供通用类型与基础能力。位于 io.agentscope.examples.compression.extra 包,实现 HttpTransport。核心成员包括 execute、stream、close、getClient、getTransportConfig、getCompressionConfig。

OkHttp transport implementation with compression support.

This class extends the standard HTTP transport functionality with:

  • Request body compression (GZIP, Brotli, Zstd)

  • Response body decompression

  • SSE stream decompression

Usage example:

`CompressionConfig compressionConfig = CompressionConfig.builder()
.enableGzipCompression()
.build();

CompressingOkHttpTransport transport = CompressingOkHttpTransport.builder()
.compressionConfig(compressionConfig)
.build();

// Use with your model client
DashScopeChatModel model = DashScopeChatModel.builder()
.apiKey("your-api-key")
.httpTransport(transport)
.build();
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
CompressingOkHttpTransport的构建器。
Builder for CompressingOkHttpTransport.

字段摘要Field Summary

字段Field类型Type说明Description
HEADER_CONTENT_ENCODING
staticfinal
String
请求头内容 ENCODING字段。
HTTP header name for content encoding.
HEADER_ACCEPT_ENCODING
staticfinal
String
请求头 ACCEPT ENCODING字段。
HTTP header name for accepted encodings.

构造器摘要Constructor Summary

构造器Constructor说明Description
public CompressingOkHttpTransport()
创建新的CompressingOkHttpTransport 使用默认配置。
Create a new CompressingOkHttpTransport with default configuration.
public CompressingOkHttpTransport(HttpTransportConfig transportConfig, CompressionConfig compressionConfig)
创建新的CompressingOkHttpTransport 使用自定义配置。
Create a new CompressingOkHttpTransport with custom configuration.
public CompressingOkHttpTransport(OkHttpClient client, HttpTransportConfig transportConfig, CompressionConfig compressionConfig)
初始化 `CompressingOkHttpTransport` 实例。
Create a new CompressingOkHttpTransport with an existing OkHttpClient.

方法摘要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 OkHttpClient getClient()
获取客户端。
Get the underlying OkHttpClient instance.
public HttpTransportConfig getTransportConfig()
获取传输层配置。
Get the transport configuration.
public CompressionConfig getCompressionConfig()
获取压缩配置。
Get the compression configuration.
public static Builder builder()
static
创建用于CompressingOkHttpTransport的构建器。
Create a new builder for CompressingOkHttpTransport.

字段详情Field Detail

HEADER_CONTENT_ENCODING

public static final String HEADER_CONTENT_ENCODING
staticfinal

请求头内容 ENCODING字段。声明为 public static final String HEADER_CONTENT_ENCODING。

HTTP header name for content encoding.

源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:78

HEADER_ACCEPT_ENCODING

public static final String HEADER_ACCEPT_ENCODING
staticfinal

请求头 ACCEPT ENCODING字段。声明为 public static final String HEADER_ACCEPT_ENCODING。

HTTP header name for accepted encodings.

源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:81

构造器详情Constructor Detail

CompressingOkHttpTransport

public CompressingOkHttpTransport()

创建新的CompressingOkHttpTransport 使用默认配置。

Create a new CompressingOkHttpTransport with default configuration.

源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:90–92

CompressingOkHttpTransport

public CompressingOkHttpTransport(HttpTransportConfig transportConfig, CompressionConfig compressionConfig)

创建新的CompressingOkHttpTransport 使用自定义配置。

Create a new CompressingOkHttpTransport with custom configuration.

参数Parameters
名称Name类型Type说明Description
transportConfigHttpTransportConfig传输层配置。the transport configuration
compressionConfigCompressionConfig压缩配置。the compression configuration
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:100–105

CompressingOkHttpTransport

public CompressingOkHttpTransport(OkHttpClient client, HttpTransportConfig transportConfig, CompressionConfig compressionConfig)

初始化 CompressingOkHttpTransport 实例。

Create a new CompressingOkHttpTransport with an existing OkHttpClient.

参数Parameters
名称Name类型Type说明Description
clientOkHttpClientOkHttpClient 到使用。the OkHttpClient to use
transportConfigHttpTransportConfig传输层配置(类型 `HttpTransportConfig`)。the transport configuration (used for reference only)
compressionConfigCompressionConfig压缩配置。the compression configuration
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:114–121

方法详情Method Detail

execute

public HttpResponse execute(HttpRequest request) throws HttpTransportException

设置执行。

Performs the execute operation.

参数Parameters
名称Name类型Type说明Description
requestHttpRequest请求(类型 `HttpRequest`)。The request.
返回Returns HttpResponse
返回HttpResponse。Returns http response.
抛出Throws
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:136–145

stream

public Flux<String> stream(HttpRequest request)

设置流。

Performs the stream operation.

参数Parameters
名称Name类型Type说明Description
requestHttpRequest请求(类型 `HttpRequest`)。The request.
返回Returns Flux<String>
返回Flux。Returns flux.
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:147–248

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:250–254

getClient

public OkHttpClient getClient()

获取客户端。

Get the underlying OkHttpClient instance.

返回Returns OkHttpClient
返回OkHttpClient。the OkHttpClient
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:261–263

getTransportConfig

public HttpTransportConfig getTransportConfig()

获取传输层配置。

Get the transport configuration.

返回Returns HttpTransportConfig
配置。the configuration
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:270–272

getCompressionConfig

public CompressionConfig getCompressionConfig()

获取压缩配置。

Get the compression configuration.

返回Returns CompressionConfig
压缩配置。the compression configuration
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:279–281

builder

public static Builder builder()
static

创建用于CompressingOkHttpTransport的构建器。

Create a new builder for CompressingOkHttpTransport.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java:428–430

嵌套类详情Nested Class Detail

Builder

public static class Builder

CompressingOkHttpTransport的构建器。位于 io.agentscope.examples.compression.extra 包。核心成员包括 transportConfig、compressionConfig、client、enableGzipCompression、build。

Builder for CompressingOkHttpTransport.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.