TsgcWebSocketProxyServerEvents › OnSSLALPNSelect

OnSSLALPNSelect Event

Fires during an ALPN-enabled handshake with a downstream client so the application can pick which protocol to negotiate.

Syntax

property OnSSLALPNSelect: TsgcWSOnSSLALPNSelect;
// TsgcWSOnSSLALPNSelect = procedure(Sender: TObject; aProtocols: TStringList; var aProtocol: String) of object

Default Value

Remarks

When a downstream client advertises Application-Layer Protocol Negotiation during the TLS handshake, OnSSLALPNSelect is raised so the proxy can decide which protocol to negotiate on the downstream leg. The aProtocols parameter is a TStringList with the names advertised by the client (for example "h2", "http/1.1"); assign aProtocol to the one that the server wants to use. Returning an empty string leaves the default behaviour in place, in which case the TLS layer picks the first advertised protocol the server supports.

Example


procedure OnSSLALPNSelect(Sender: TObject; aProtocols: TStringList;
  var aProtocol: String);
begin
  if aProtocols.IndexOf('h2') >= 0 then
    aProtocol := 'h2'
  else
    aProtocol := 'http/1.1';
end;

Back to Events