TsgcHTTP2ClientMethods › Options

Options Method

Performs a synchronous HTTP/2 OPTIONS request to discover the communication options of a resource.

Overloads

Overload 1

Syntax

function Options(const aURL: string): string;

Parameters

NameTypeDescription
aURLconst stringAbsolute URL of the resource whose capabilities are being queried, or * to query the server as a whole.

Return Value

Response body returned by the server as a string; the useful information is usually in the response headers. (string)

Remarks

OPTIONS is commonly used by browsers for CORS preflight and by clients to probe which methods are accepted. Inspect Request.Headers after the call to read the allow, access-control-allow-* and related headers.

Example

vResponse := oClient.Options('https://api.example.com/v1/users');

Overload 2

Syntax

procedure Options(Const aURL: string; const aResponseContent: TStream);

Parameters

NameTypeDescription
aURLconst stringAbsolute URL of the resource being interrogated.
aResponseContentconst TStreamCaller-owned stream that receives the response body, if the server returns any.

Remarks

Stream-based variant of OPTIONS. Use it when the response payload should be routed to an arbitrary TStream rather than materialised as a string.

Example

oOut := TMemoryStream.Create;
try
  oClient.Options('https://api.example.com/v1/users', oOut);
finally
  oOut.Free;
end;

Back to Methods