download file by URL by TscHttpWebRequest , how to get progress ??
Thanks
How to get TscHttpWebRequest progress?
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: How to get TscHttpWebRequest progress?
Hi Andy!
Thanks for your question!
To display the progress of download, you need to process TScHttpWebResponse.OnProgress event as follow:
Should you have any other questions, feel free to ask!
Regards,
Vitaliy
Thanks for your question!
To display the progress of download, you need to process TScHttpWebResponse.OnProgress event as follow:
Code: Select all
var
ScHttpWebResponse: TScHttpWebResponse;
...
ScHttpWebResponse := ScHttpWebRequest.GetResponse();
ScHttpWebResponse.OnProgress := DoOnProgress;
//perform reading of response content
...
procedure TForm1.DoOnProgress(Sender: TObject; Total, Current: Int64; var Cancel: boolean);
begin
//here you can display a progress
//assign Cancel := True; to stop downloading;
end;
Regards,
Vitaliy
Re: How to get TscHttpWebRequest progress?
Hello,
I tried this but got the following error messages:
Here is a code snippet:
I am using Lazarus 2.0.12 with FPC 3.2.2. What are the correct parameters?
Can you please update your documentation? There are many missing parts!
I tried this but got the following error messages:
Code: Select all
uutilshttp.pas(70,30) Error: Wrong number of parameters specified for call to "DoOnProgress"
uutilshttp.pas(32,15) Error: Found declaration: DoOnProgress(TObject;Int64;Int64;var Boolean);
Code: Select all
function TUtilsHTTP.GetHTTPResponse(URL: string; out HTTPResponse: string): boolean;
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
begin
...
Response := Request.GetResponse;
Response.OnProgress := DoOnProgress;
...
end;
procedure TUtilsHTTP.DoOnProgress(Sender: TObject; Total, Current: int64;
var Cancel: boolean);
begin
// Stop Download, wenn notwendig
Cancel := FCancelDownload;
end;
Can you please update your documentation? There are many missing parts!
Re: How to get TscHttpWebRequest progress?
I got it...
is the solution for Lazarus. Sry my fault.
But there are still a lot of missing parts in the documentation...
Code: Select all
Response.OnProgress := @DoOnProgress;
But there are still a lot of missing parts in the documentation...
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: How to get TscHttpWebRequest progress?
Hi there!
Thanks for the info provided!
Could you please inform us about the issues you have experienced, so that we could be able to improve our documentation?
Looking forward to your reply!
Thanks for the info provided!
Could you please inform us about the issues you have experienced, so that we could be able to improve our documentation?
Looking forward to your reply!