Builder
public static class Builder
源码Source
io/agentscope/core/model/transport/HttpResponse.java:87–145HttpResponse的构建器。位于 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 |
|---|---|---|
statusCode | int | 状态 Code(类型 `int`)。the status code |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpResponse.java:98–101header
public Builder header(String name, String value)
设置请求头。
Add a header to the response.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 请求头名称。the header name |
value | String | 请求头值。the header value |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpResponse.java:110–113headers
public Builder headers(Map<String, String> headers)
设置请求头。
Add multiple headers to the response.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
headers | Map<String, String> | 请求头到添加。the headers to add |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpResponse.java:121–124body
public Builder body(String body)
设置响应正文。
Set the response body.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
body | String | 正文(类型 `String`)。the body string |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpResponse.java:132–135build
public HttpResponse build()
构建HttpResponse。
Build the HttpResponse.
HttpResponse一种新的HttpResponse 实例。a new HttpResponse instance
源码Source
io/agentscope/core/model/transport/HttpResponse.java:142–144