API Reference
StreamSec.Http.Rest
StreamSec Tools - A REST client over the library's own TLS stack
Feature notes: HTTPS application layer notes (HTTP/1.1, h2, h3)
Classes, interfaces and records
classeRESTError
inherits from Exception
(no public members)
classTsmCustomRESTClient
inherits from TComponent
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
function BeginPinnedSession: Boolean; virtual;
ONE TLS CONNECTION ACROSS SEVERAL CALLS, and the channel binding of it. WHY IT EXISTS. A protocol that authenticates INSIDE the tunnel - a challenge in one call and the answer to it in the next - is only as good as its assurance that both calls went down the same channel.
Full description »
procedure EndPinnedSession; virtual;
Ends the session and closes the connection. Safe to call when no session is open, and safe to call twice; the destructor calls it.
» member page
function PinnedSessionLive: Boolean; virtual;
True while a session is open AND unbroken. False the moment the pinned connection is found gone, which is what a caller polls to find out that its exchange can no longer be completed.
» member page
function ChannelBinding(out aBinding: tBytes): Boolean; virtual;
The RFC 9266 tls-exporter binding of the pinned connection. False - with aBinding empty - when there is no live pinned session, or the connection offers no binding (not TLS 1.3, handshake unfinished).
Full description »
function ExecuteRaw(const aMethod, aPath, aBody, aContentType, aAuthHeader, aIdempotencyKey: string; out aStatus: Integer; out aRespBody: string): Boolean;
THE RAW CALL: one exchange with the given Authorization header verbatim, NO retry. This is what an auth subclass uses to fetch a token - it must not recurse through the retry path. aContentType '' omits the header; aIdempotencyKey '' omits it. Answers False on transport failure.
» member page
function Execute(const aMethod, aPath, aBody, aContentType, aIdempotencyKey: string; out aStatus: Integer; out aRespBody: string): Boolean;
THE ORDINARY CALL: computes the Authorization header from AuthorizationHeader, runs the exchange, and on a single 401 asks Reauthorize and retries once. Serialised, so a token refresh races nobody.
» member page
function ExecuteJson(const aMethod, aPath, aBody, aContentType, aIdempotencyKey: string; out aStatus: Integer; out aJson: tJsonValue): Boolean;
Execute, then parse the body as JSON. aJson is nil when the body was empty or unparseable; the caller owns and frees it. The HTTP status is still reported - a 4xx with a JSON error body parses like any other.
» member page
property Lock: TCriticalSection read fLock;
The lock the retry path holds; exposed so a subclass token-fetch can share the same serialisation when it needs to.
» member page
property BaseURL: string read fBaseURL write fBaseURL;
The scheme+host(+port) every path is joined to, e.g. 'https://api.example.com' or 'https://sandbox.example.com:8443'. No trailing slash. A port given here is the one connected to; without one it is 443.
» member page
property UserAgent: string read fUserAgent write fUserAgent;
property Accept: string read fAccept write fAccept;
The Accept header sent on every call. Default 'application/json'.
» member page
The header name an idempotency key is sent under - 'PayPal-Request-Id', 'Idempotency-Key', etc. Emitted lowercase on the wire regardless. Default 'Idempotency-Key'.
» member page
property RevocationChecking: tRESTRevocationChecking read fRevocation write fRevocation default rvcSoft;
What happens when revocation status is inconclusive. Default rvcSoft.
» member page
property Timeout: Cardinal read fTimeout write fTimeout;
Milliseconds a transport waits on the peer: for each handshake round while connecting, and for each receive after that - the head of the response and every piece of its body. Handed to every transport this client builds, the pinned one included. Default 30000.
» member page
An OPERATOR-supplied extra trust anchor file (.cer/.der/.p7b), ADDED to whatever ConfigureTrust installs - never replacing it. A CA rollover, a private deployment. Empty is the norm.
» member page
property TLSEngine: TsmSimpleTLSInternalServer read fTLSEngine write SetTLSEngine;
THE TLS ENGINE THIS CLIENT RUNS ON, supplied and OWNED BY THE CALLER. Assign one - and keep it for the life of the client - when calls REPEAT.
Full description »
property OnLog: tRESTLogEvent read fOnLog write fOnLog;
property OnConfigureTrust: tRESTConfigureTrustEvent read fOnConfigureTrust write fOnConfigureTrust;
property OnAuthorization: tRESTAuthorizationEvent read fOnAuthorization write fOnAuthorization;
property OnReauthorize: tRESTReauthorizeEvent read fOnReauthorize write fOnReauthorize;
inherits from TsmCustomRESTClient
The palette component - the published surface with nothing added. A subclass that supplies trust and auth is the usual way this is used.
(no public members)
Types (enumerations, sets, aliases)
enumtRESTRevocationChecking
What to do when the peer's revocation status cannot be established. The names mirror the TLS stack's TRevocationPolicy without dragging its unit into every consumer's uses clause.
tRESTRevocationChecking = (rvcSoft, { inconclusive = proceed (the default) }
rvcHard, { inconclusive = fail }
rvcOff); { do not check at all }
proctRESTLogEvent
Emitted for one line of diagnostics; never carries a credential.
tRESTLogEvent = procedure (const aText: string) of object;
A dropped-in instance wires its anchors here instead of subclassing.
tRESTConfigureTrustEvent = procedure (Sender: TObject;
aEngine: TsmSimpleTLSInternalServer)
of object;
proctRESTAuthorizationEvent
Supplies the Authorization header for the next call - '' for none. A token-cache consumer mints or returns its token here.
tRESTAuthorizationEvent = procedure (Sender: TObject;
var aHeader: string) of object;
proctRESTReauthorizeEvent
A call came back 401; refresh the credential and set aRetry True to retry once.
tRESTReauthorizeEvent = procedure (Sender: TObject;
var aRetry: Boolean) of object;