K
K
krka922019-07-15 18:03:47
Delphi
krka92, 2019-07-15 18:03:47

How to download a file from the Internet without using Indy?

How to download a file from the Internet without using Indy?
It is advisable to use a lib that is not tied to Windows. You will need to run the binary on Linux

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hemul GM, 2019-07-31
@krka92

THTTPClient to System.Net.HttpClient.

function DownloadURL(URL: string): TMemoryStream;
var
  HTTP: THTTPClient;
begin
  Result := TMemoryStream.Create;
  HTTP := THTTPClient.Create;
  try
    try
      HTTP.HandleRedirects := True;
      HTTP.Get(URL, Result);
    except
      //Ну, ошибка... Поток всё равно создан и ошибки не должно возникнуть,
      //если проверить размер потока перед его использованием
    end;
  finally
    HTTP.Free;
  end;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question