🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
11 messages
11 total messages Started by MR Mon, 13 Feb 2006 19:12
How to make TIdHTTP::Get() show it's current progress-state?
#939
Author: MR
Date: Mon, 13 Feb 2006 19:12
23 lines
1521 bytes
Is there a way to make TIdHTTP::Get() show it's current
progress-state, like it is displayed in IE when downloading a file?

I tried to modify my current code 

  TFileStream *stream=new TFileStream(dst_file,
fmCreate|fmShareDenyRead);
  try {
    TIdHTTP->Get(_web_address, stream);
  }
  ...

in the hope I can limit the stream's buffer to a certain number of
bytes and recall Get() again until the whole file is donwloaded, but
unfortunately without success.

Naturally I'm not too fixed on TIdHTTP::Get. If there is another way
with which this is possible, please let me know...


Thanks a lot,

Michael
Re: How to make TIdHTTP::Get() show it's current progress-state?
#940
Author: Remy Lebeau (TeamB)
Date: Mon, 13 Feb 2006 23:17
17 lines
1482 bytes
<MR> wrote in message news:rpl1v11s7qjgne4qgo2ihebrn2of6sg3iu@4ax.com...

> Is there a way to make TIdHTTP::Get() show it's current
> progress-state, like it is displayed in IE when downloading
> a file?

Use the OnWork events to update your own progress UI.

>   TFileStream *stream=new TFileStream(dst_file,
> fmCreate|fmShareDenyRead);

You cannot specify any flags with fmCreate.  They will be ignored, and the
file will always be opened with exclusive access.


Gambit
Re: How to make TIdHTTP::Get() show it's current progress-state?
#942
Author: MR
Date: Tue, 14 Feb 2006 07:34
19 lines
1445 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> schrieb:

>
><MR> wrote in message news:rpl1v11s7qjgne4qgo2ihebrn2of6sg3iu@4ax.com...
>
>> Is there a way to make TIdHTTP::Get() show it's current
>> progress-state, like it is displayed in IE when downloading
>> a file?
>
>Use the OnWork events to update your own progress UI.

Oh, thank you, that works fine.

Is there a way to find out how many bytes to be read at all. This
would allow to use a progress-bar, displaying the progress in percent.

Thank you,

Michael
Re: How to make TIdHTTP::Get() show it's current progress-state?
#943
Author: Remy Lebeau (TeamB)
Date: Tue, 14 Feb 2006 09:01
12 lines
1498 bytes
<MR> wrote in message news:uaq2v1pj3n56hemn0hjimm4cpacb8rnibg@4ax.com...

> Is there a way to find out how many bytes to be read at all.

Yes, but not 100% reliably.  There is the TIdHTTP.Response.ContentLength
property, but it is only valid if the server reported the file's length
ahead of time.  Depending on how the file is being transferred internally
(chunked, compressed, etc), the file's length is not always available.


Gambit
Re: How to make TIdHTTP::Get() show it's current progress-state?
#947
Author: MR
Date: Wed, 15 Feb 2006 06:50
16 lines
1801 bytes
>Yes, but not 100% reliably.  There is the TIdHTTP.Response.ContentLength
>property, but it is only valid if the server reported the file's length
>ahead of time.  Depending on how the file is being transferred internally
>(chunked, compressed, etc), the file's length is not always available.

This works fine, thank you.

Fortunately/Unfurtunately with my tries I get always(!) useful
information in TIdHTTP.Response.ContentLength, I suppose
TIdHTTP.Response.ContentLength has a value of 0, if the real size
could not be find out in advance!? Is this assumption correct or is
there another way?

Thanks,

Michael
Re: How to make TIdHTTP::Get() show it's current progress-state?
#948
Author: Remy Lebeau (TeamB)
Date: Wed, 15 Feb 2006 18:17
17 lines
1645 bytes
<MR> wrote in message news:okj5v11entds8ea5fs7q8u8n1j2ve1sj33@4ax.com...

> Fortunately/Unfurtunately with my tries I get always(!) useful
> information in TIdHTTP.Response.ContentLength

That is not always guaranteed.

> I suppose TIdHTTP.Response.ContentLength has a value of 0
> if the real size could not be find out in advance!?

No.  It will be -1 , not 0, if the 'Content-Length' header is not present.
Also, the HasContentLength property will be False, in which case the value
of the ContentLength property has to be ignored.


Gambit
Re: How to make TIdHTTP::Get() show it's current progress-state?
#949
Author: MR
Date: Wed, 15 Feb 2006 19:05
1 lines
1221 bytes
Thank you...
Re: How to make TIdHTTP::Get() show it's current progress-state?
#951
Author: MR
Date: Sat, 18 Feb 2006 13:17
16 lines
1742 bytes
Sorry, I thought I now know all, but there is still one thing: is
there a way to get the ContentLength without trying to get 'Get()' the
whole file.

I was looking for a kind of 'bool &Stop'-argument in the
OnWorkBegin/OnWork()-methods of TIdHTTP, but did not found anything.

Than I tried to raise/catch an exception from TIdHTTP::WorkStart,
after I got the ContentLength from OnWorkBegin() to stop the
downloading-process, but now get some strange Timeout-Exceptions
(after a time >2min) and suppose this might be the reason. Probably
that's a bad way and there is a much better one...

Thanks a lot,

Michael
Re: How to make TIdHTTP::Get() show it's current progress-state?
#952
Author: Remy Lebeau (TeamB)
Date: Sat, 18 Feb 2006 19:42
18 lines
1795 bytes
<MR> wrote in message news:2h7ev1h8dng1re80ip1cmk1luibgrv7cfs@4ax.com...

> is there a way to get the ContentLength without trying
> to get 'Get()' the whole file.

Use the Head() method.  The HEAD command retreives just the headers, whereas
the GET command retreives the headers and the content.

> I was looking for a kind of 'bool &Stop'-argument in the
> OnWorkBegin/OnWork()-methods of TIdHTTP, but did
> not found anything.

There is nothing in Indy 9 for that.  In Indy 10, there is a new
OnHeadersAvailable event which has a VContinue parameter.


Gambit
Re: How to make TIdHTTP::Get() show it's current progress-state?
#953
Author: MR
Date: Sun, 19 Feb 2006 00:11
10 lines
1484 bytes
All works now fine and it seems indeed that this strange delay when
trying to get the the ContentLength-information came from my
exception-construct in the OnWorkBegin().

As I've head in another thread Indy10 does not work with BDS2006's
BCB-personality. 

Thanks a lot, 

Michael
Re: How to make TIdHTTP::Get() show it's current progress-state?
#954
Author: Remy Lebeau (TeamB)
Date: Sun, 19 Feb 2006 01:42
10 lines
1508 bytes
<MR> wrote in message news:necfv1lle4i8o7r2gavmm2jn3jlfr1ig0m@4ax.com...

> As I've head in another thread Indy10 does not work
> with BDS2006's BCB-personality.

It will be shortly.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads