1
votes

I had all kind of problems with Indy and following someone’s recommendations (at stackoverflow) I have updated to the latest version of Indy - at least this is what I intended to do.

Before starting the installation, I have manually deleted all files containing the "indy" word from my Delphi and from registry. Then I have followed the standard install procedure: http://www.indyproject.org/sockets/Docs/Indy10Installation.en.aspx

Now the piece of code below is not working anymore. The code just returns FALSE;

function Download(CONST aSourceURL: string; CONST aDestFileName: string; OUT aErrm: String): Boolean;
VAR
  Stream: TMemoryStream;
  IDAntiFreeze: TIDAntiFreeze;
  fIDHTTP : TIDHTTP;
begin
  fIDHTTP := TIDHTTP.Create(NIL);
//  fIDHTTP.ConnectTimeout:=5000;     <- not recognized
  fIDHTTP.ReadTimeout:= 1000;
  fIDHTTP.HandleRedirects := TRUE;
  fIDHTTP.AllowCookies := FALSE;
  fIDHTTP.Request.UserAgent := 'Mozilla/4.0';
  fIDHTTP.Request.Connection := 'Keep-Alive';
  fIDHTTP.Request.ProxyConnection := 'Keep-Alive';
  fIDHTTP.Request.CacheControl := 'no-cache';
  IDAntiFreeze := TIDAntiFreeze.Create(NIL);

  Stream := TMemoryStream.Create;
  TRY
    TRY
      fIDHTTP.Get(aSourceURL, Stream);
      {
      if FileExists(aDestFileName)
      then DeleteFile(PWideChar(aDestFileName)); }

      Stream.SaveToFile(aDestFileName);
      Result:= TRUE;
    EXCEPT
      On E: Exception do
        begin
          Result:= FALSE;
          aErrm := E.Message + ' (' + IntToStr(fIDHTTP.ResponseCode) + ')';
        end;
    END;
  FINALLY
    Stream.Free;
    IDAntiFreeze.Free;
    fIDHTTP.Free;
  END;
end; 

There is any way to see which version of Indy I have installed?

Edit: Also I get an "Unit idHTTP was compiled with a different version of IdException.IdException" message. Fixed.

1
Sounds like you have a bad install, such as if you did not completely remove the older version before installing a newer one (just looking for files with "indy" in the name is not enough).Remy Lebeau
The installation works now (indeed I had to clean Delphi folders really well and the registry also. However, the code still doesn't download the file.External Server Error
What exactly is not working now? Are you getting errors? Bad file data? You need to be more specific. In any case, I would suggest you get rid of the TIdAntiFreeze and move the download into a separate worker thread. If you need Download() to be a blocking function, it can wait on the thread to finish its work.Remy Lebeau

1 Answers

2
votes

You should first use the Delphi setup to uninstall the version of Indy that is installed with Delphi - then you can cleanup any remaining file. You should not start by cleaning folders and registry by hand. Then you can install another version. Be aware some releases are "breaking"