Article View: borland.public.cppbuilder.internet.web
Article #453Re: downloading with wininet
From: Remy Lebeau (TeamB)
Date: Tue, 02 Jan 2007 20:30
Date: Tue, 02 Jan 2007 20:30
70 lines
3790 bytes
3790 bytes
"Boba" <Boba@somewhere.world> wrote in message
news:459ab27c@newsgroups.borland.com...
> the error checking has been stripped off to simplify the post.
> there is no code line where it fails: it is the result of
downloading
> that is sometimes wrong. at random, the file i get is the 406 error
> message (none of the code lines report a failure).
Well, you are not checking the actual response code to begin with
before downloading the file. 406 is a "not acceptable" error. You
have to use HttpQueryInfo() to verify the server's reply before you
can decide whether the file is ok to download or not.
> some servers never send 406; others - like the one in my
> sample - do it at no obvious reason for that.
I am assuming that you have not read RFC 2616 yet:
Hypertext Transfer Protocol -- HTTP/1.1
http://www.ietf.org/rfc/rfc2616.txt
10.4.7 406 Not Acceptable
The resource identified by the request is only capable of
generating
response entities which have content characteristics not
acceptable
according to the accept headers sent in the request.
Unless it was a HEAD request, the response SHOULD include an
entity
containing a list of available entity characteristics and
location(s)
from which the user or user agent can choose the one most
appropriate. The entity format is specified by the media type
given
in the Content-Type header field. Depending upon the format
and the
capabilities of the user agent, selection of the most
appropriate
choice MAY be performed automatically. However, this
specification
does not define any standard for such automatic selection.
Note: HTTP/1.1 servers are allowed to return responses which
are
not acceptable according to the accept headers sent in the
request. In some cases, this may even be preferable to sending
a
406 response. User agents are encouraged to inspect the
headers of
an incoming response to determine if it is acceptable.
If the response could be unacceptable, a user agent SHOULD
temporarily stop receipt of more data and query the user for a
decision on further actions.
> i do read everything (not shown for the sake of simplicity).
You are calling InternetReadFile() once, and only once, for each call
to InternetQueryDataAvailable(). If the size of the available data is
larger than your buffer, or InterntReadFile() cannot return that much
data in a single call, then you are NOT reading all of the available
data properly. That is why you must loop the call to
InterntReadFile() to ensure all available data is read in full.
Gambit
Technical Details
Message-ID:
<459ac541$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4599f9c5@newsgroups.borland.com> <459a2c13$1@newsgroups.borland.com> <459a89d6@newsgroups.borland.com> <459aac49$1@newsgroups.borland.com> <459ab27c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,66a46201c905b896 X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <4599f9c5@newsgroups.borland.com> <459a2c13$1@newsgroups.borland.com> <459a89d6@newsgroups.borland.com> <459aac49$1@newsgroups.borland.com> <459ab27c@newsgroups.borland.com> Subject: Re: downloading with wininet Date: Tue, 2 Jan 2007 12:30:49 -0800 Lines: 72 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.34.171 Message-ID: <459ac541$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1167770945 75.83.34.171 (2 Jan 2007 12:49:05 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail