TsgcHTTP3Client › Methods › Patch
Sends a synchronous HTTP/3 PATCH request carrying a partial-update payload.
function Patch(const aURL: string; const aData: string;
const aContentType: string = 'application/json'): string; overload;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource. |
aData | const string | Request body. It is encoded as UTF-8 before being sent in the HTTP/3 DATA frame. |
aContentType | const string | Value of the content-type request header. Defaults to application/json. |
Response body received from the server, decoded as a string. (string)
procedure Patch(const aURL: string; const aSource: TStream;
const aResponseContent: TStream); overload;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource. |
aSource | TStream | Stream read in full from position 0 and sent as the request body. May be nil to send an empty body. |
aResponseContent | TStream | Stream that receives the response body. |
None. The response body is written to aResponseContent.
The call blocks the calling thread until the complete response has been received. When the client is not connected yet, the URL is used to open the QUIC connection first. For a non-blocking request use PatchAsync, which delivers the reply on OnResponse.
PATCH applies a partial modification to the target resource, so only the changed fields travel in the body. Unlike Put it is not required to be idempotent. The string overload defaults aContentType to application/json.
The stream overload always sends content-type: application/octet-stream. It does not accept an aContentType parameter, so when the server requires a specific media type use the string overload instead.
vBody := '{"email": "john@example.com"}';
vResponse := oClient.Patch('https://api.example.com/v1/users/1', vBody);