TsgcSSEClient › Events › OnBeforeConnect

OnBeforeConnect Event

Fires before every connection attempt with the HTTP client, to configure TLS, proxy and authentication.

Syntax

property OnBeforeConnect: TsgcSSEBeforeConnectEvent;
// TsgcSSEBeforeConnectEvent = procedure(Sender: TObject; const aHTTP: TsgcHTTP1Client) of object

Default Value

—

Remarks

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.

Example


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;

Back to Events