TsgcHTTP2ClientMethods › Trace

Trace Method

Performs a synchronous HTTP/2 TRACE request used to debug the request path between client and server.

Overloads

Overload 1

Syntax

function Trace(Const aURL: string): string;

Parameters

NameTypeDescription
aURLconst stringAbsolute URL to target. The request headers (potentially modified by proxies in the path) will be echoed back by the origin server.

Return Value

Response body containing the echoed request, as a message/http document. (string)

Remarks

TRACE performs a message loop-back test: the server replies with the exact request line and headers it received, making it useful for diagnosing which proxies or gateways alter traffic. Many servers disable TRACE for security reasons, so be prepared to receive 405 Method Not Allowed.

Example

vEcho := oClient.Trace('https://api.example.com/diag');

Overload 2

Syntax

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

Parameters

NameTypeDescription
aURLconst stringAbsolute URL to target with the TRACE request.
aResponseContentconst TStreamStream that captures the echoed message/http response body.

Remarks

Stream-based overload. Convenient when the echoed request is long (for example when many proxy via headers have been added) and you prefer to persist it to disk or a memory buffer for later analysis.

Example

oOut := TFileStream.Create('trace.log', fmCreate);
try
  oClient.Trace('https://api.example.com/diag', oOut);
finally
  oOut.Free;
end;

Back to Methods