TsgcHTTP3Client › Events › OnAltSvc
Fires when the server advertises alternative services through the alt-svc header.
TsgcAltSvcEvent = procedure(Sender: TObject;
const aEntries: TsgcAltSvcList) of object;
property OnAltSvc: TsgcAltSvcEvent read FOnAltSvc write FOnAltSvc;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcHTTP3Client instance that raised the event. |
aEntries | const TsgcAltSvcList | Array of TsgcAltSvcEntry records parsed from the header. Each has Protocol (the ALPN token, for example h3), Host, Port, MaxAge (seconds the entry stays valid) and Persist. |
The alt-svc header (RFC 7838) is how a server says the same resource is also reachable somewhere else, typically on another port or over a newer protocol. This event fires whenever a response carries one, with the header already parsed into records.
Use it to discover where a service prefers to be reached and to cache that hint for MaxAge seconds. Applying it means connecting to the advertised host and port on the next connection.
The event does not fire for a header that only clears previously advertised alternatives, and it does not fire when no entry could be parsed. The client does not act on the advertisement by itself: switching endpoints is the application decision.
procedure TfrmMain.OnAltSvcEvent(Sender: TObject; const aEntries: TsgcAltSvcList);
var
i: Integer;
begin
for i := 0 to Length(aEntries) - 1 do
Log(Format('%s on %s:%d (max-age %d)', [aEntries[i].Protocol,
aEntries[i].Host, aEntries[i].Port, aEntries[i].MaxAge]));
end;