Builder
public static class Builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:90–163HttpRequest的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 url、method、header、headers、body、build。
Builder for HttpRequest.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Builder url(String url) | 设置请求 URL。 Set the request URL. |
public Builder method(String method) | 设置HTTP 方法。 Set the HTTP method. |
public Builder header(String name, String value) | 设置请求头。 Add a header to the request. |
public Builder headers(Map<String, String> headers) | 设置请求头。 Add multiple headers to the request. |
public Builder body(String body) | 设置请求正文。 Set the request body. |
public HttpRequest build() | 构建HttpRequest。 Build the HttpRequest. |
方法详情Method Detail
url
public Builder url(String url)
设置请求 URL。
Set the request URL.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
url | String | 服务地址(类型 `String`)。the URL |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:102–105method
public Builder method(String method)
设置HTTP 方法。
Set the HTTP method.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
method | String | 方法(类型 `String`)。the method (GET, POST, etc.) |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:113–116header
public Builder header(String name, String value)
设置请求头。
Add a header to the request.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 请求头名称。the header name |
value | String | 请求头值。the header value |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:125–128headers
public Builder headers(Map<String, String> headers)
设置请求头。
Add multiple headers to the request.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
headers | Map<String, String> | 请求头到添加。the headers to add |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:136–139body
public Builder body(String body)
设置请求正文。
Set the request body.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
body | String | 正文(类型 `String`)。the body string |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/core/model/transport/HttpRequest.java:147–150build
public HttpRequest build()
构建HttpRequest。
Build the HttpRequest.
HttpRequest一种新的HttpRequest 实例。a new HttpRequest instance
源码Source
io/agentscope/core/model/transport/HttpRequest.java:157–162