Recent

Author Topic: [indy] download file using alternative IP  (Read 2085 times)

MisterE

  • New Member
  • *
  • Posts: 13
[indy] download file using alternative IP
« on: July 12, 2014, 08:13:52 pm »
Hi,

I need to download a file (probably a json file). I should use a www-adsress (local address) but the IP must be configurable (we host two system with the same www-address.
Futhermore i should be able to use a proxy.

I can not test it at this moment because the json-feature is not included yet.

I found this code





procedure TForm1.Button1Click(Sender: TObject);
  var
  Buffer: TFileStream;
  HttpClient: TIdHttp;
begin
  Buffer := TFileStream.Create('somefile.exe', fmCreate or fmShareDenyWrite);
  try
    HttpClient := TIdHttp.Create(nil);

    try
      HttpClient.Get('http://somewhere.com/somefile.exe', Buffer); // wait until it is done
    finally
      HttpClient.Free;
    end;
  finally
    Buffer.Free;
  end;
end;
           
Is this the right approach?
And this the right code to use a proxy: http://www.indyproject.org/kb/index.html?iuseindywithahttpproxy.htm

Then how can is change the resolving of "somewhere.com", thus not using DNS but my own defined IP.

Thanks in advance.

 

TinyPortal © 2005-2018