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?
Author: MR
Date: Mon, 13 Feb 2006 19:12
Date: Mon, 13 Feb 2006 19:12
23 lines
1521 bytes
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?
Author: Remy Lebeau (TeamB)
Date: Mon, 13 Feb 2006 23:17
Date: Mon, 13 Feb 2006 23:17
17 lines
1482 bytes
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?
Author: MR
Date: Tue, 14 Feb 2006 07:34
Date: Tue, 14 Feb 2006 07:34
19 lines
1445 bytes
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?
Author: Remy Lebeau (TeamB)
Date: Tue, 14 Feb 2006 09:01
Date: Tue, 14 Feb 2006 09:01
12 lines
1498 bytes
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?
Author: MR
Date: Wed, 15 Feb 2006 06:50
Date: Wed, 15 Feb 2006 06:50
16 lines
1801 bytes
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?
Author: Remy Lebeau (TeamB)
Date: Wed, 15 Feb 2006 18:17
Date: Wed, 15 Feb 2006 18:17
17 lines
1645 bytes
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?
Author: MR
Date: Wed, 15 Feb 2006 19:05
Date: Wed, 15 Feb 2006 19:05
1 lines
1221 bytes
1221 bytes
Thank you...
Re: How to make TIdHTTP::Get() show it's current progress-state?
Author: MR
Date: Sat, 18 Feb 2006 13:17
Date: Sat, 18 Feb 2006 13:17
16 lines
1742 bytes
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?
Author: Remy Lebeau (TeamB)
Date: Sat, 18 Feb 2006 19:42
Date: Sat, 18 Feb 2006 19:42
18 lines
1795 bytes
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?
Author: MR
Date: Sun, 19 Feb 2006 00:11
Date: Sun, 19 Feb 2006 00:11
10 lines
1484 bytes
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?
Author: Remy Lebeau (TeamB)
Date: Sun, 19 Feb 2006 01:42
Date: Sun, 19 Feb 2006 01:42
10 lines
1508 bytes
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