AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/model/transport/HttpRequest.java:90–163

HttpRequest的构建器。位于 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
urlString服务地址(类型 `String`)。the URL
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/model/transport/HttpRequest.java:102–105

method

public Builder method(String method)

设置HTTP 方法。

Set the HTTP method.

参数Parameters
名称Name类型Type说明Description
methodString方法(类型 `String`)。the method (GET, POST, etc.)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/model/transport/HttpRequest.java:113–116

headers

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

设置请求头。

Add multiple headers to the request.

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

body

public Builder body(String body)

设置请求正文。

Set the request body.

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

build

public HttpRequest build()

构建HttpRequest。

Build the HttpRequest.

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