TsgcHTTP3Client › Methods › Put
Sends a synchronous HTTP/3 PUT request with a request body.
function Put(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 Put(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 PutAsync, which delivers the reply on OnResponse.
PUT replaces the target resource with the supplied representation and is idempotent, so repeating an identical PUT has the same effect as sending it once. 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 := '{"name": "John"}';
// aContentType defaults to application/json
vResponse := oClient.Put('https://api.example.com/v1/users/1', vBody);