TsgcHTTP3Client › 方法 › GetAsync
发送非阻塞 HTTP/3 GET 请求;回复通过 OnResponse 传递。
procedure GetAsync(const aURL: string);
| 名称 | 类型 | 描述 |
|---|---|---|
aURL | const string | 要获取的资源的绝对 URL。查询字符串参数应已编码。 |
GetAsync 发送 HTTP/3 GET 请求后立即返回,不阻塞调用线程。收到完整响应后,结果通过 OnResponse 事件传递;若请求失败,则触发 OnError。使用异步方法可保持用户界面响应,或在同一 HTTP/3 连接上并发发送多个请求。如需阻塞式调用并直接返回响应体,请使用 Get。
oClient.OnResponse := OnResponseEvent;
oClient.GetAsync('https://api.example.com/v1/users');
procedure OnResponseEvent(Sender: TObject; const Response: TsgcHTTP3Response);
begin
ShowMessage(Response.DataString);
end;