TsgcHTTP3Client › 方法 › PostAsync

PostAsync 方法

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

语法

procedure PostAsync(const aURL: string; const aData: string; const aContentType: string = 'application/x-www-form-urlencoded');

参数

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

备注

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

示例


oClient.OnResponse := OnResponseEvent;
oClient.PostAsync('https://api.example.com/v1/login', 'user=john&pass=secret');

返回方法