TsgcHTTP3Client › 方法 › PutAsync

PutAsync 方法

发送非阻塞 HTTP/3 PUT 请求;回复通过 OnResponse 传递。

语法

procedure PutAsync(const aURL: string; const aData: string; const aContentType: string = 'application/json');

参数

名称类型描述
aURLconst string请求发送目标资源的绝对 URL。
aDataconst string发送给服务器的请求正文。
aContentTypeconst stringcontent-type 标头的值。默认为 application/json。

备注

PutAsync 发送 HTTP/3 PUT 请求后立即返回,不阻塞调用线程。收到完整响应后,结果通过 OnResponse 事件传递;若请求失败,则触发 OnError。请将 aContentType 设置为与负载匹配的值,例如发送 JSON 文档时设为 application/json。如需阻塞式调用并直接返回响应体,请使用 Put。

示例


oClient.OnResponse := OnResponseEvent;
oClient.PutAsync('https://api.example.com/v1/users/42', '{"name":"john"}');

返回方法