Handling HTTP redirects in Downloader

Check also Multipart Multithreaded Downloading
 
procedure TForm1.btnDownloadClick(Sender: TObject);   
begin   
   Memo1.Lines.Clear();   
   FRedirectURL := '';   
   clDownLoader.URL := edtURL.Text;   
   clDownLoader.Start();   
end;    
  
procedure TForm1.clInternetConnectionStatusCallback(Sender: TObject;   
   Action: TclInternetAction; AInternetStatus: Integer;   
   AStatusInformation: PChar; AStatusInformationLength: Integer);   
begin   
   if (AInternetStatus = INTERNET_STATUS_REDIRECT) then   
   begin   
      FRedirectURL := AStatusInformation;   
      clDownLoader.Stop();   
   end;   
end;    
  
procedure TForm1.clDownLoaderProcessCompleted(Sender: TObject);   
begin   
   if (FRedirectURL <> '') then   
   begin   
      clDownLoader.URL := FRedirectURL;   
      if (clDownLoader.LocalFile = clDownLoader.LocalFolder) then   
      begin   
         clDownLoader.LocalFile := clDownLoader.LocalFile + 'default.htm';   
      end;   
      FRedirectURL := '';   
      clDownLoader.Start();   
   end;   
end;

Add Feedback