How to retrieve a file from Internet via HTTP?

后端 未结 6 2139
天命终不由人
天命终不由人 2020-12-30 17:46

I want to download a file from Internet and InternetReadFile seem a good and easy solution at the first glance. Actually, too good to be true. Indeed, digging a bit I have s

6条回答
  •  失恋的感觉
    2020-12-30 18:11

    I recommend Synapse. It's small, stable and easy-to-use (no need of any external libraries).

    Example from httpsend.pas

    function HttpGetText(const URL: string; const Response: TStrings): Boolean;
    var
      HTTP: THTTPSend;
    begin
      HTTP := THTTPSend.Create;
      try
        Result := HTTP.HTTPMethod('GET', URL);
        if Result then
          Response.LoadFromStream(HTTP.Document);
      finally
        HTTP.Free;
      end;
    end;
    

提交回复
热议问题