TsgcHTTP3Client › 方法 › Put
发送携带正文负载的同步 HTTP/3 PUT 请求并返回响应体。
function Put(const aURL: string; const aData: string; const aContentType: string = 'application/json'): string; overload;
procedure Put(const aURL: string; const aSource: TStream; const aResponseContent: TStream); overload;
| 名称 | 类型 | 描述 |
|---|---|---|
aURL | const string | 请求发送目标资源的绝对 URL。 |
aData | const string | 发送给服务器的请求正文。 |
aContentType | const string | content-type 标头的值。默认为 application/json。 |
aSource | TStream | 用作请求正文的流(仅流重载)。 |
aResponseContent | TStream | 接收原始响应体的流(仅流重载)。 |
从服务器接收的响应体,解码为字符串。流重载将正文写入 aResponseContent。(string)
Put 阻塞调用线程直至收到完整的 HTTP/3 响应。使用第一个重载发送字符串正文,并将 aContentType 设为与负载匹配的值;使用流重载从 TStream 发送请求正文并将回复写入另一个流。如需非阻塞请求,请使用 PutAsync,它将回复传递到 OnResponse。
vResponse := oClient.Put('https://api.example.com/v1/users/42', '{"name":"john"}');