AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/model/transport/HttpResponse.java:87–145

HttpResponse的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 statusCode、header、headers、body、build。

Builder for HttpResponse.

方法摘要Method Summary

方法Method说明Description
public Builder statusCode(int statusCode)
设置该配置项。
Set the HTTP status code.
public Builder header(String name, String value)
设置请求头。
Add a header to the response.
public Builder headers(Map<String, String> headers)
设置请求头。
Add multiple headers to the response.
public Builder body(String body)
设置响应正文。
Set the response body.
public HttpResponse build()
构建HttpResponse。
Build the HttpResponse.

方法详情Method Detail

statusCode

public Builder statusCode(int statusCode)

设置该配置项。

Set the HTTP status code.

参数Parameters
名称Name类型Type说明Description
statusCodeint状态 Code(类型 `int`)。the status code
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/model/transport/HttpResponse.java:98–101

headers

public Builder headers(Map<String, String> headers)

设置请求头。

Add multiple headers to the response.

参数Parameters
名称Name类型Type说明Description
headersMap<String, String>请求头到添加。the headers to add
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/model/transport/HttpResponse.java:121–124

body

public Builder body(String body)

设置响应正文。

Set the response body.

参数Parameters
名称Name类型Type说明Description
bodyString正文(类型 `String`)。the body string
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/model/transport/HttpResponse.java:132–135

build

public HttpResponse build()

构建HttpResponse。

Build the HttpResponse.

返回Returns HttpResponse
一种新的HttpResponse 实例。a new HttpResponse instance
源码Source io/agentscope/core/model/transport/HttpResponse.java:142–144
基于官方固定版本源码静态生成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.