TsgcSSEClient › Events › OnBeforeConnect
Fires before every connection attempt with the HTTP client, to configure TLS, proxy and authentication.
property OnBeforeConnect: TsgcSSEBeforeConnectEvent;
// TsgcSSEBeforeConnectEvent = procedure(Sender: TObject; const aHTTP: TsgcHTTP1Client) of object
—
The stream is read with a TsgcHTTP1Client. This event gives access to it before the request is sent, on the first connection and on every reconnection, so TLS options, a proxy, authentication or timeouts can be set. It always runs on the background thread.
procedure TForm1.OnSSEBeforeConnect(Sender: TObject;
const aHTTP: TsgcHTTP1Client);
begin
// TLS
aHTTP.TLSOptions.Version := tls1_2;
aHTTP.TLSOptions.IOHandler := iohOpenSSL;
// proxy
aHTTP.Proxy.Enabled := True;
aHTTP.Proxy.Host := '192.168.1.10';
aHTTP.Proxy.Port := 8080;
// basic authentication
aHTTP.Request.BasicAuthentication := True;
aHTTP.Request.Username := 'user';
aHTTP.Request.Password := 'secret';
aHTTP.ReadTimeout := 60000;
end;