Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Http.AltSvc

Feature notes: HTTPS application layer notes (HTTP/1.1, h2, h3)

Classes, interfaces and records

recordtHttpAltSvcOrigin

Host, Authority, Key: string; Port: Word;

recordtHttpAltSvcAlternative

Host: string; Port: Word; Generation: UInt64;

interfaceiHttpAltSvcCache

WHERE TsmCustomHTTPSClient REMEMBERS HTTP/3 ALTERNATIVES that servers advertised with Alt-Svc (HTTPSClient.txt, CACHE AND ORIGIN RULES). Each client starts with a private one. To let several clients share what any of them learns, create one with NewHttpAltSvcCache and assign it to their AltSvcCache while they are disconnected - but only between clients with the same trust configuration, since all of them then use its routes. The client makes every call below itself; an application normally only creates, assigns and clears a cache. A custom implementation must be thread-safe and must never call back into a client. Build each origin with TryHttpAltSvcOrigin: Learn and TrySelect ignore a record whose Key and Authority do not match its Host and Port. Take every aNowMS from one monotonic millisecond clock (the client uses stTlsUtils.GetTickCount64).

procedure Learn(const aOrigin: tHttpAltSvcOrigin; const aFieldValue: string; aNowMS, aResponseAgeMS: UInt64);
Records what one response advertised. Call it only for a final (non-1xx) response received over a connection authenticated for that origin, with all its Alt-Svc field values joined by ','; do not call it for a response without the field, which changes nothing. Full description »
function TrySelect(const aOrigin: tHttpAltSvcOrigin; aNowMS: UInt64; out aAlternative: tHttpAltSvcAlternative): Boolean;
True, with the route in aAlternative, while the origin has a fresh route that Failed is not suppressing: try HTTP/3 on aAlternative.Port. False, with aAlternative empty: use TCP.
procedure Failed(const aOrigin: tHttpAltSvcOrigin; const aAlternative: tHttpAltSvcAlternative; aNowMS: UInt64);
After a failed attempt to connect to aAlternative: suppresses that route for 30 seconds, never past its expiry. Ignored when the origin has learned its route again since TrySelect returned aAlternative.
procedure Rejected(const aOrigin: tHttpAltSvcOrigin; const aAlternative: tHttpAltSvcAlternative);
Removes aAlternative because it refused the origin; the client calls it on a 421 (Misdirected Request) received over HTTP/3. Ignored when the origin has learned its route again since then.
procedure ClearOrigin(const aOrigin: tHttpAltSvcOrigin);
Removes the origin's route, whatever its age; the client calls it when it cannot trust a response's Alt-Svc, Date or Age fields.
procedure Clear;
Removes every route. TsmCustomHTTPSClient.ClearAltSvcCache calls it, so on a shared cache it clears the routes of every client using it.

Routines