#1 2012-08-19 08:20:51

zaki
Member
Registered: 2012-08-19
Posts: 4

WinInet WinHttp Usage Demo

Hi,

i fround your page on http://stackoverflow.com/questions/6725 … i-wrapper/ link.

I need file downloader with using wininet and https.

You can write file downloader -like below- with your unit.
Or any sample?

procedure DownloadHTTP(const AUrl : string; DestStream: TStream);
begin
  with TIdHTTP.Create(Application) do
  try
      try
        Get(AUrl,DestStream);
      except
        On e : Exception do
          MessageDlg(Format('Erreur : %s',[e.Message]), mtInformation, [mbOK], 0);
      end;
  finally
      Free;
  end;
end;

Note: code from http://stackoverflow.com/questions/4521 … component/

Thanks.

Offline

#2 2012-08-20 07:28:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,269
Website

Re: WinInet WinHttp Usage Demo

Something like that:

procedure DownloadHTTP(const Server, Port, Url: AnsiString; DestStream: TStream);
var Header,Data: TSockData;
begin
  with TWinINet.Create(Server,Port,true) do // Https=true
  try
      try
        if Request(Url,'GET',false,'','','',Header,Data)=200 then
          DestStream.Write(Data[1],length(Data));
      except
        On e : Exception do
          MessageDlg(Format('Erreur : %s',[e.Message]), mtInformation, [mbOK], 0);
      end;
  finally
      Free;
  end;
end;

Offline

Board footer

Powered by FluxBB