TsgcHTTP3Client › Methods › Patch

Patch Method

Sends a synchronous HTTP/3 PATCH request carrying a partial-update payload.

Syntax

Patch(const aURL, aData: string; const aContentType: string): string string overload

function Patch(const aURL: string; const aData: string;

  const aContentType: string = 'application/json'): string; overload;
NameTypeDescription
aURLconst stringAbsolute URL of the target resource.
aDataconst stringRequest body. It is encoded as UTF-8 before being sent in the HTTP/3 DATA frame.
aContentTypeconst stringValue of the content-type request header. Defaults to application/json.

Response body received from the server, decoded as a string. (string)

Patch(const aURL: string; const aSource, aResponseContent: TStream) stream overload

procedure Patch(const aURL: string; const aSource: TStream;

  const aResponseContent: TStream); overload;
NameTypeDescription
aURLconst stringAbsolute URL of the target resource.
aSourceTStreamStream read in full from position 0 and sent as the request body. May be nil to send an empty body.
aResponseContentTStreamStream that receives the response body.

None. The response body is written to aResponseContent.

Remarks

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.

Example



vBody := '{"email": "john@example.com"}';

vResponse := oClient.Patch('https://api.example.com/v1/users/1', vBody);

Back to Methods