TsgcHTTP2ClientEvents › OnHTTP2BeforeRequest

OnHTTP2BeforeRequest Event

Fires just before request headers are sent so the application can add or modify them.

Syntax

property OnHTTP2BeforeRequest: TsgcHTTPClientBeforeRequestEvent;
// TsgcHTTPClientBeforeRequestEvent = procedure(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; var Headers: TStringList) of object

Default Value

Remarks

OnHTTP2BeforeRequest is raised right before the client serializes the HEADERS frame and sends it to the HTTP/2 server, giving the application a last chance to inspect or adjust the headers for the current request. The Headers parameter is a TStringList in "Name: Value" form pre-populated with the default headers plus anything configured in Request.CustomHeaders; add, remove or replace entries to customize the outgoing request. Because the event is raised per request, it is the right place to inject dynamic values (authentication tokens, correlation IDs, feature flags) that cannot be set once in the component.

Example


procedure OnHTTP2BeforeRequest(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient;
  var Headers: TStringList);
begin
  Headers.Add('Client: sgcWebSockets');
end;

Back to Events