Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

indy GET dowloading speed

Welcome,

I have to create caption with information about downloading speed in my application using indy http get compontent.

In my mind i found simple solution.

At onwork event i will get actual progress of downloading (size) and compare it with previous reading. (for example every 5 seconds). curent size minus previous (5 seconds eariel, stored in global var) divide by 5 seconds * 8 and i will get speed. If actual size is equal previous then sped is always 0.

So i want start codding, but i found problem in simple function called odwork.

procedure TForm1.HttpWork(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCount: Int64);
  begin
    showmessage('hello im herre');
end;  

Problem is, that function isnt called... I don't know why.

I'm downloading 100 MB file, and i cant see any showmessage...

Have any idea ? Regards

like image 248
marc Avatar asked Nov 05 '22 05:11

marc


1 Answers

The OnWork... events are only fired if the connection's BeginWork() method has been called beforehand. Many of Indy's reading/writing methods do not call that automatically. However, TIdHTTP reads/writes request/response body data using TStream objects, and the connection's read/write TStream methods do call BeginWork() internally, so you will definately get OnWork... events fired during HTTP operations.

like image 111
Remy Lebeau Avatar answered Nov 09 '22 12:11

Remy Lebeau