Idhttp pick up downloaded file size

3

Well, I would like to know how to find out the size of the file being downloaded with the IdHttp component.

    
asked by anonymous 24.10.2014 / 08:38

1 answer

4

You have to request the HEAD operation with the file address

var
  HttpClient: TIdHttp;
  FileSize: Int64;
begin
  HttpClient := TIdHttp.Create(nil);
  try
    HttpClient.Head('http://somewhere.com/somefile.exe');
    FileSize := HttpClient.Response.ContentLength;
  finally
    HttpClient.Free;
  end;
end;
    
24.10.2014 / 12:38