TsgcHTTP2Client方法 › PutAsync

PutAsync 方法

发送非阻塞 HTTP/2 PUT 请求;服务器回复通过 OnHTTP2Response 投递。

语法

procedure PutAsync(const aURL: string; const aSource: TStream);

参数

名称类型描述
aURLconst string标识将要创建或替换的资源的绝对 URL。
aSourceconst TStream提供要存储的资源完整表示的流。

备注

Put 的非阻塞变体。调用在流被序列化为 HTTP/2 DATA 帧后立即返回;确认(状态码、标头和正文)稍后通过 OnHTTP2Response 返回。适用于不得冻结的 UI 驱动代码路径。

示例

oClient.OnHTTP2Response := OnHTTP2ResponseEvent;
oBody := TStringStream.Create('{"status":"active"}');
try
  oClient.Request.ContentType := 'application/json';
  oClient.PutAsync('https://api.example.com/users/42', oBody);
finally
  oBody.Free;
end;

返回方法