|
|
@@ -17,17 +17,21 @@ uses
|
|
|
type
|
|
|
TOnDownloadProgress = function(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean of object;
|
|
|
TOnSimpleDownloadProgress = procedure(const Bytes, Param: Integer64);
|
|
|
+ TOnDownloadNoProgress = procedure of object;
|
|
|
+ TOnSimpleDownloadNoProgress = procedure;
|
|
|
|
|
|
function DownloadFile(const Url, CustomUserName, CustomPassword: String;
|
|
|
const DestF: TFile; [ref] const Verification: TSetupFileVerification; const ISSigSourceFilename: String;
|
|
|
const OnSimpleDownloadProgress: TOnSimpleDownloadProgress;
|
|
|
- const OnSimpleDownloadProgressParam: Integer64): Int64;
|
|
|
+ const OnSimpleDownloadProgressParam: Integer64;
|
|
|
+ const OnSimpleDownloadNoProgress: TOnSimpleDownloadNoProgress): Int64;
|
|
|
|
|
|
function DownloadTemporaryFile(const Url, BaseName: String;
|
|
|
- [ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress): Int64; overload;
|
|
|
+ [ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress;
|
|
|
+ const OnDownloadNoProgress: TOnDownloadNoProgress): Int64; overload;
|
|
|
function DownloadTemporaryFile(const Url, BaseName: String;
|
|
|
[ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress;
|
|
|
- out DestFile: String): Int64; overload;
|
|
|
+ const OnDownloadNoProgress: TOnDownloadNoProgress; out DestFile: String): Int64; overload;
|
|
|
function DownloadTemporaryFileSize(const Url: String): Int64;
|
|
|
function DownloadTemporaryFileDate(const Url: String): String;
|
|
|
procedure SetDownloadTemporaryFileCredentials(const User, Pass: String);
|
|
|
@@ -59,8 +63,10 @@ type
|
|
|
FUser, FPass: String;
|
|
|
FDestFile: TFile;
|
|
|
FOnDownloadProgress: TOnDownloadProgress;
|
|
|
+ FOnDownloadNoProgress: TOnDownloadNoProgress;
|
|
|
FOnSimpleDownloadProgress: TOnSimpleDownloadProgress;
|
|
|
FOnSimpleDownloadProgressParam: Integer64;
|
|
|
+ FOnSimpleDownloadNoProgress: TOnSimpleDownloadNoProgress;
|
|
|
FLock: TObject;
|
|
|
FProgress, FProgressMax: Int64;
|
|
|
FProgressSet: Boolean;
|
|
|
@@ -76,8 +82,10 @@ type
|
|
|
destructor Destroy; override;
|
|
|
property BaseName: String write FBaseName;
|
|
|
property OnDownloadProgress: TOnDownloadProgress write FOnDownloadProgress;
|
|
|
+ property OnDownloadNoProgress: TOnDownloadNoProgress write FOnDownloadNoProgress;
|
|
|
property OnSimpleDownloadProgress: TOnSimpleDownloadProgress write FOnSimpleDownloadProgress;
|
|
|
property OnSimpleDownloadProgressParam: Integer64 write FOnSimpleDownloadProgressParam;
|
|
|
+ property OnSimpleDownloadNoProgress: TOnSimpleDownloadNoProgress write FOnSimpleDownloadNoProgress;
|
|
|
property Aborted: Boolean read FAbort;
|
|
|
property Progress: Int64 read FProgress;
|
|
|
property ProgressMax: Int64 read FProgressMax;
|
|
|
@@ -208,6 +216,11 @@ begin
|
|
|
else
|
|
|
raise;
|
|
|
end;
|
|
|
+ end else begin
|
|
|
+ if Assigned(FOnDownloadNoProgress) then
|
|
|
+ FOnDownloadNoProgress
|
|
|
+ else if Assigned(FOnSimpleDownloadNoProgress) then
|
|
|
+ FOnSimpleDownloadNoProgress;
|
|
|
end;
|
|
|
|
|
|
if DownloadTemporaryFileOrExtractArchiveProcessMessages then
|
|
|
@@ -323,7 +336,8 @@ end;
|
|
|
function DownloadFile(const Url, CustomUserName, CustomPassword: String;
|
|
|
const DestF: TFile; [ref] const Verification: TSetupFileVerification; const ISSigSourceFilename: String;
|
|
|
const OnSimpleDownloadProgress: TOnSimpleDownloadProgress;
|
|
|
- const OnSimpleDownloadProgressParam: Integer64): Int64;
|
|
|
+ const OnSimpleDownloadProgressParam: Integer64;
|
|
|
+ const OnSimpleDownloadNoProgress: TOnSimpleDownloadNoProgress): Int64;
|
|
|
var
|
|
|
HTTPDataReceiver: THTTPDataReceiver;
|
|
|
begin
|
|
|
@@ -336,6 +350,7 @@ begin
|
|
|
try
|
|
|
HTTPDataReceiver.OnSimpleDownloadProgress := OnSimpleDownloadProgress;
|
|
|
HTTPDataReceiver.OnSimpleDownloadProgressParam := OnSimpleDownloadProgressParam;
|
|
|
+ HTTPDataReceiver.OnSimpleDownloadNoProgress := OnSimpleDownloadNoProgress;
|
|
|
|
|
|
{ Download to specified handle }
|
|
|
Result := HTTPDataReceiver.Download(False);
|
|
|
@@ -366,7 +381,7 @@ end;
|
|
|
|
|
|
function DownloadTemporaryFile(const Url, BaseName: String;
|
|
|
[ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress;
|
|
|
- out DestFile: String): Int64;
|
|
|
+ const OnDownloadNoProgress: TOnDownloadNoProgress; out DestFile: String): Int64;
|
|
|
var
|
|
|
TempFile: String;
|
|
|
TempF: TFile;
|
|
|
@@ -430,6 +445,7 @@ begin
|
|
|
try
|
|
|
HTTPDataReceiver.BaseName := BaseName;
|
|
|
HTTPDataReceiver.OnDownloadProgress := OnDownloadProgress;
|
|
|
+ HTTPDataReceiver.OnDownloadNoProgress := OnDownloadNoProgress;
|
|
|
|
|
|
{ To test redirects: https://jrsoftware.org/download.php/is.exe
|
|
|
To test expired certificates: https://expired.badssl.com/
|
|
|
@@ -492,10 +508,11 @@ begin
|
|
|
end;
|
|
|
|
|
|
function DownloadTemporaryFile(const Url, BaseName: String;
|
|
|
- [ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress): Int64;
|
|
|
+ [ref] const Verification: TSetupFileVerification; const OnDownloadProgress: TOnDownloadProgress;
|
|
|
+ const OnDownloadNoProgress: TOnDownloadNoProgress): Int64;
|
|
|
begin
|
|
|
var DestFile: String;
|
|
|
- Result := DownloadTemporaryFile(Url, BaseName, Verification, OnDownloadProgress, DestFile);
|
|
|
+ Result := DownloadTemporaryFile(Url, BaseName, Verification, OnDownloadProgress, OnDownloadNoProgress, DestFile);
|
|
|
end;
|
|
|
|
|
|
procedure DownloadTemporaryFileSizeAndDate(const Url: String; var FileSize: Int64; var FileDate: String);
|