Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: Wininet.dll & HTTPQueryInfo

www.cryer.info
Managed Newsgroup Archive

Re: Wininet.dll & HTTPQueryInfo

Subject:Re: Wininet.dll & HTTPQueryInfo
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Fri, 9 Mar 2007 11:05:39

"MikeR" <nf4lNoSpam@pobox.com> wrote in message
news:45f17863@newsgroups.borland.com...

> Using Wininet.dll, I can download a file using the following URL
> and code. I'd like to get the filesize using HTTPQueryInfo so I
> can implement a progress bar. HTTPQueryInfo returns
> ERROR_HTTP_HEADER_NOT_FOUND.

Then the server is not sending a "Content-Length" header.  Without
seeing the actual HTTP traffic, my guess would be that a chunked
transfer is occuring.  In other words, the "Transfer-Encoding" header
includes "chunked", and the file is then received in an unspecified
number of blocks.  You can use HTTP_QUERY_TRANSFER_ENCODING to verify
that.

If that is the case, then there is not way to know the size of the
data during the actual transfer.  You would have to send a separate
HEAD request beforehand.  Since the data is likely generated
dynamically, however, the size may not exactly match what is actually
being downloaded afterwards, so watch out for that.  Otherwise, during
a chunked transfer (or any other transfer that does not include the
"Content-Length" header), you would not be able to use a progress bar
at all, so you would just have to show the running number of bytes
received instead.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive