Setting Up HTTP Proxy Parameters in TCP-based Client Components

1. Assigning HTTP proxy to the TclDownloader, TclUploader, TclMultiDownloader, and TclMultiUploader components.

All these components provide two special properties for both HTTP and FTP hosts: HttpProxySettings and FtpProxySettings, correspondingly.
 
 
procedure TForm1.btnDownloaderClick(Sender: TObject);
begin
  if clDownloader1.IsBusy then Exit;

  clDownloader1.HttpProxySettings.UserName := 'user';
  clDownloader1.HttpProxySettings.Password := 'psw';
  clDownloader1.HttpProxySettings.Server := 'proxy-domain.com';
  clDownloader1.HttpProxySettings.Port := 8080;

  clDownloader1.URL := 'https://www.clevercomponents.com/checknews/clnews.html';
  clDownloader1.LocalFile := 'clnews.html';

  clDownLoader1.Start();
end;
 

2. Assigning HTTP proxy to the TclHttp component.

 
procedure TForm1.btnHttpClick(Sender: TObject);
var
  response: string;
begin
  clHttp1.ProxySettings.UserName := 'user';
  clHttp1.ProxySettings.Password := 'psw';
  clHttp1.ProxySettings.Server := 'proxy-domain.com';
  clHttp1.ProxySettings.Port := 8080;

  response := clHttp1.Get('https://www.clevercomponents.com/checknews/clnews.html');
end;
 

3. Assigning HTTP proxy to the TclFtp component.

procedure TForm1.btnFtpProxyClick(Sender: TObject);
begin
  clFtp1.ProxySettings.UserName := 'user';
  clFtp1.ProxySettings.Password := 'psw';
  clFtp1.ProxySettings.Server := 'proxy-domain.com';
  clFtp1.ProxySettings.Port := 8080;
  clFtp1.ProxySettings.ProxyType := ptHttpConnect;

  clFtp1.UserName := 'ftp-user';
  clFtp1.Password := 'secret';
  clFtp1.Server := 'ftp-host';
  clFtp1.Port := 21;
  clFtp1.Open();
end;
 

4. Assigning HTTP proxy to the TclSmtp component.

The SMTP protocol doesn't directly support HTTP proxy. You need to add an additional component, TclHttpProxy, and assign the TclSmtp.Proxy property with an instance of this component. Other TCP-based client components (TclImap4, TclPop3, TclSFtp, etc.) are configured in the same way.
 
procedure TForm1.btnSmtpClick(Sender: TObject);
begin
  clHttpProxy1.UserName := 'user';
  clHttpProxy1.Password := 'psw';
  clHttpProxy1.Server := 'proxy-domain.com';
  clHttpProxy1.Port := 8080;

  clSmtp1.Proxy := clHttpProxy1;
  clSmtp1.UserName := 'mail-user';
  clSmtp1.Password := 'secret';
  clSmtp1.Server := 'mail-host';
  clSmtp1.Port := 25;
  clSmtp1.Open();
end;

Add Feedback