TsgcHTTP2Client › Methods › Put
Performs a synchronous HTTP/2 PUT, replacing the resource at the URL with the uploaded content.
function Put(const aURL: string; const aSource: TStream): string;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL identifying the resource that will be created or replaced. |
aSource | const TStream | Stream supplying the full representation of the resource to store. |
Response body received from the server decoded as a string. (string)
PUT is idempotent: calling it repeatedly with the same body yields the same resource state on the server. This overload is suited to JSON / text payloads whose textual response can be consumed as a string.
oBody := TStringStream.Create('{"status":"active"}');
try
oClient.Request.ContentType := 'application/json';
vResponse := oClient.Put('https://api.example.com/users/42', oBody);
finally
oBody.Free;
end;
procedure Put(const aURL: string; const aSource: TStream; const aResponseContent: TStream);
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL identifying the resource to create or replace. |
aSource | const TStream | Stream supplying the resource bytes to upload. |
aResponseContent | const TStream | Stream that captures the raw response body from the server. |
Stream-to-stream variant recommended for binary resource uploads, such as image or file replacements, where both the request and the response are best handled without string conversion.
oIn := TFileStream.Create('avatar.png', fmOpenRead);
oOut := TMemoryStream.Create;
try
oClient.Put('https://api.example.com/users/42/avatar', oIn, oOut);
finally
oOut.Free;
oIn.Free;
end;