TsgcHTTP3Client › 方法 › Patch

Patch 方法

发送携带正文负载的同步 HTTP/3 PATCH 请求并返回响应体。

语法

function Patch(const aURL: string; const aData: string; const aContentType: string = 'application/json'): string; overload;
procedure Patch(const aURL: string; const aSource: TStream; const aResponseContent: TStream); overload;

参数

名称类型描述
aURLconst string请求发送目标资源的绝对 URL。
aDataconst string发送给服务器的部分更新请求正文。
aContentTypeconst stringcontent-type 标头的值。默认为 application/json。
aSourceTStream用作请求正文的流(仅流重载)。
aResponseContentTStream接收原始响应体的流(仅流重载)。

返回值

从服务器接收的响应体,解码为字符串。流重载将正文写入 aResponseContent。(string)

备注

Patch 对资源应用部分更新,并阻塞调用线程直至收到完整的 HTTP/3 响应。与替换资源的 Put 不同,PATCH 仅发送变更部分。使用第一个重载发送字符串正文,使用流重载从 TStream 发送正文并将回复写入另一个流。如需非阻塞请求,请使用 PatchAsync,它将回复传递到 OnResponse。

示例


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

返回方法