TsgcHTTP2Client › Methods › Patch
Performs a synchronous HTTP/2 PATCH, applying a partial modification to the target resource.
function Patch(const aURL: string; const aSource: TStream): string;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the resource to be partially updated. |
aSource | const TStream | Stream holding the patch document (for example a JSON Patch or JSON Merge Patch body). |
Response body returned by the server decoded as a string. (string)
Unlike PUT, PATCH sends only the fields that should change. Ensure Request.ContentType matches the patch format expected by the server (e.g. application/json-patch+json or application/merge-patch+json).
oBody := TStringStream.Create('{"email":"new@example.com"}');
try
oClient.Request.ContentType := 'application/merge-patch+json';
vResponse := oClient.Patch('https://api.example.com/users/42', oBody);
finally
oBody.Free;
end;
procedure Patch(const aURL: string; const aSource: TStream; const aResponseContent: TStream);
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the resource to be partially updated. |
aSource | const TStream | Stream containing the patch payload. |
aResponseContent | const TStream | Stream that captures the raw response from the server. |
Fully streamed variant. Suitable when the patch document or the response representation is large enough that a string round-trip would be wasteful.
oIn := TFileStream.Create('patch.json', fmOpenRead);
oOut := TMemoryStream.Create;
try
oClient.Patch('https://api.example.com/users/42', oIn, oOut);
finally
oOut.Free;
oIn.Free;
end;