TsgcWebSocketProxyServerEvents › OnHandshake

OnHandshake Event

Fires after the handshake with a downstream client is evaluated and before the response is sent.

Syntax

property OnHandshake: TsgcWSHandshakeEvent;
// TsgcWSHandshakeEvent = procedure(Connection: TsgcWSConnection; var Headers: TStringList) of object

Default Value

Remarks

OnHandshake is raised immediately after a downstream client's HTTP upgrade request has been parsed and validated, and before the handshake response is written back. The incoming headers sent by the client are available through the HeadersRequest property of the connection (cast to TsgcWSConnectionServer). The Headers parameter is a TStringList containing the response lines that will be returned; add custom lines (for example a vendor-specific header) to include them in the HTTP response. Standard WebSocket headers (Upgrade, Connection, Sec-WebSocket-Accept...) are already populated and should not be duplicated. This event applies to the downstream WebSocket leg only; the proxy does not perform a WebSocket handshake against the upstream TCP server.

Example


procedure OnServerHandshake(Connection: TsgcWSConnection; var Headers: TStringList);
begin
  ShowMessage(TsgcWSConnectionServer(Connection).HeadersRequest.Text);
end;

Back to Events