WebSocket Custom Headers

WebSocket protocol starts with an HTTP Handshake similar to normal HTTP Request, this handshake has an address request, origin, protocols supported... sometimes is useful to add some custom headers. sgcWebSockets supports customize HandShake Headers using OnHandshake event of Client WebSocket Component. There is a parameter called Headers which is a TStringList that contains a list of headers will be sent to Server, you can modify these headers or add your custom headers.

Example: add header "x-my-header" with value "test"


procedure OnClientHandshake(Connection: TsgcWSConnection; var Headers: TStringList);


  Headers.Add('x-my-hader: test');