Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-01

TFPHttpClient: download progress (or status).

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

First, sorry for my various requests. I'm contributing to improves this beautiful class.

So, how to show a download progress?

I think that the method "ReadResponse" should have two callbacks, like as "AContentLenght" and "AContentPosition". What do you think?

Thank you!

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130123/4bc2bfad/attachment.html>

Reply by email

silvioprog
to silvioprog

2013/1/23 silvioprog

Show quoted text 12 lines
Hello, First, sorry for my various requests. I'm contributing to improves this beautiful class. So, how to show a download progress? I think that the method "ReadResponse" should have two callbacks, like as "AContentLenght" and "AContentPosition". What do you think? Thank you!

Hm... If you change this internal funcion to a class method ...:

  Function Transfer(LB : Integer) : Integer;
  begin
    Result:=FSocket.Read(FBuffer[1],LB);
    If Result<0 then
      Raise EHTTPClient.Create(SErrReadingSocket);
    if (Result>0) then
      Stream.Write(FBuffer[1],Result);
  end;

... the progress of download will be possible, getting the currenty stream size (or position?). :)

ps. i don't tested with chuncked content. :/

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130123/65bdf0c8/attachment.html>

Reply by email

silvioprog
to silvioprog

2013/1/23 silvioprog

Show quoted text 31 lines
2013/1/23 silvioprog > Hello, > > First, sorry for my various requests. I'm contributing to improves this > beautiful class. > > So, how to show a download progress? > > I think that the method "ReadResponse" should have two callbacks, like as > "AContentLenght" and "AContentPosition". What do you think? > > Thank you! > Hm... If you change this internal funcion to a class method ...: Function Transfer(LB : Integer) : Integer; begin Result:=FSocket.Read(FBuffer[1],LB); If Result<0 then Raise EHTTPClient.Create(SErrReadingSocket); if (Result>0) then Stream.Write(FBuffer[1],Result); end; ... the progress of download will be possible, getting the currenty stream size (or position?). :) ps. i don't tested with chuncked content. :/

What do you think about implementa this method?:

(...)
public
    procedure ReadingResponse(const ASize, APosition: Int64); virtual;
(...)

Called internally by ReadResponse. (triggered by normal and chunked reading)

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130123/f098dc00/attachment-0001.html>

Reply by email

silvioprog
to silvioprog

2013/1/23 silvioprog

Show quoted text 8 lines
[...] What do you think about implementa this method?: (...) public procedure ReadingResponse(const ASize, APosition: Int64); virtual; (...)

Or only:

    procedure ReadingResponse(AStream: TStream); virtual;
Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130123/c6fa953a/attachment.html>

Reply by email

Michael Van Canneyt
to silvioprog
silvioprog wrote 5 lines
2013/1/23 silvioprog [...] I was thinking to myself... an initial idea:

Please post a feature request.

I think one event

   TOnProgressEvent = (Sender : TObject; BytesRead,ContentLength : Int64) of object;

should be enough.

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

2013/1/23 Michael Van Canneyt

Show quoted text 15 lines
On Wed, 23 Jan 2013, silvioprog wrote: > 2013/1/23 silvioprog > [...] > > I was thinking to myself... an initial idea: > Please post a feature request. I think one event TOnProgressEvent = (Sender : TObject; BytesRead,ContentLength : Int64) of object; should be enough. Michael.

Done:

http://bugs.freepascal.org/view.php?id=23734

Depending on how you implement it, i think that i can do a "download resumed".

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130123/57de7994/attachment-0001.html>

Reply by email