TsgcHTTP2ClientMethods › PutAsync

PutAsync Method

Sends a non-blocking HTTP/2 PUT; the server's reply is delivered on OnHTTP2Response.

Syntax

procedure PutAsync(const aURL: string; const aSource: TStream);

Parameters

NameTypeDescription
aURLconst stringAbsolute URL identifying the resource that will be created or replaced.
aSourceconst TStreamStream supplying the full representation of the resource to store.

Remarks

Non-blocking variant of Put. The call returns as soon as the stream has been serialised into HTTP/2 DATA frames; confirmation (status code, headers and body) is handed back later on OnHTTP2Response. Useful in UI-driven code paths that must not freeze.

Example

oClient.OnHTTP2Response := OnHTTP2ResponseEvent;
oBody := TStringStream.Create('{"status":"active"}');
try
  oClient.Request.ContentType := 'application/json';
  oClient.PutAsync('https://api.example.com/users/42', oBody);
finally
  oBody.Free;
end;

Back to Methods