TsgcHTTP2Client › Methods › GetFuture
Runs an HTTP/2 GET on a background thread and returns a future that resolves to the response body.
function GetFuture(const aURL: string): IsgcFuture<string>;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the resource to retrieve. |
An IsgcFuture<string> that resolves to the response body. Call Await to block until the response arrives, ThenProc to consume the body in a continuation, OnError to handle failures, and Cancel to abort the request.
GetFuture is the future-style counterpart of the synchronous Get: the request runs on a background thread and the method returns immediately, so the calling thread is never blocked. Unlike ConnectAsync and the other Async verbs, no event handler is required: the response is delivered through the returned future. Calling Cancel disconnects the client, so a request still waiting for its response is aborted instead of running to completion; an aborted or failed request rejects the future with an exception delivered to OnError (or re-raised by Await). Requires Delphi 2010 or later (and C++Builder 2010 or later); it is not available in the .NET edition.
oClient.GetFuture('https://www.esegece.com')
.ThenProc(procedure(const aBody: string)
begin
WriteLn(aBody);
end)
.OnError(procedure(E: Exception)
begin
WriteLn('Request failed: ' + E.Message);
end);