BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to make TIdHTTP::Get() show it's current progress-state?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web)
View previous topic :: View next topic  
Author Message
MR
Guest





PostPosted: Mon Feb 13, 2006 8:03 pm    Post subject: How to make TIdHTTP::Get() show it's current progress-state? Reply with quote



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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Feb 14, 2006 12:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote



<MR> wrote in message news:rpl1v11s7qjgne4qgo2ihebrn2of6sg3iu (AT) 4ax (DOT) com...

Quote:
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.

Quote:
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
Back to top
MR
Guest





PostPosted: Tue Feb 14, 2006 8:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote



"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> schrieb:

Quote:

MR> wrote in message news:rpl1v11s7qjgne4qgo2ihebrn2of6sg3iu (AT) 4ax (DOT) 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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Feb 14, 2006 10:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

<MR> wrote in message news:uaq2v1pj3n56hemn0hjimm4cpacb8rnibg (AT) 4ax (DOT) com...

Quote:
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
Back to top
MR
Guest





PostPosted: Wed Feb 15, 2006 8:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

Quote:
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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Feb 15, 2006 7:03 pm    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

<MR> wrote in message news:okj5v11entds8ea5fs7q8u8n1j2ve1sj33 (AT) 4ax (DOT) com...

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

That is not always guaranteed.

Quote:
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
Back to top
MR
Guest





PostPosted: Wed Feb 15, 2006 8:03 pm    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

Thank you...
Back to top
MR
Guest





PostPosted: Sat Feb 18, 2006 2:03 pm    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 18, 2006 8:03 pm    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

<MR> wrote in message news:2h7ev1h8dng1re80ip1cmk1luibgrv7cfs (AT) 4ax (DOT) com...

Quote:
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.

Quote:
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
Back to top
MR
Guest





PostPosted: Sun Feb 19, 2006 1:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Feb 19, 2006 2:03 am    Post subject: Re: How to make TIdHTTP::Get() show it's current progress-st Reply with quote

<MR> wrote in message news:necfv1lle4i8o7r2gavmm2jn3jlfr1ig0m (AT) 4ax (DOT) com...

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

It will be shortly.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.