Article View: borland.public.cppbuilder.internet.web
Article #457Re: downloading with wininet
From: Remy Lebeau (TeamB)
Date: Wed, 03 Jan 2007 01:06
Date: Wed, 03 Jan 2007 01:06
56 lines
3254 bytes
3254 bytes
"Boba" <Boba@somewhere.world> wrote in message
news:459acad3@newsgroups.borland.com...
> i do loop InternetReadFile untill dwBytesDownloaded becomes 0.
No, you are not. I quote your original code:
do{
if( InternetQueryDataAvailable( hHttpRequest, &dwDataSize, 0,
0 ) ){
if( InternetReadFile( hHttpRequest, (LPVOID)Buffer,
sizeof(Buffer), &dwBytesDownloaded ) ){
/*write the data*/
}//if( InternetReadFile
}//if( InternetQueryDataAvailable(
} while( dwBytesDownloaded );
You are looping InternetQueryDataAvailable(), not InternetReadFile().
Again, if you do not read ALL of the data that
InternetQueryDataAvailable() reports in a single call, it CANNOT
report more data until the previous data queue is emptied. This is
clearly stated by Microsoft's documentation:
InternetQueryDataAvailable
http://msdn2.microsoft.com/en-us/library/aa385100.aspx
"This function returns the number of bytes of data that are
available to be read immediately by a subsequent call to
InternetReadFile. If there is currently no data available and the end
of the file has not been reached, the request waits until data becomes
available. The amount of data remaining will not be recalculated until
all available data indicated by the call to InternetQueryDataAvailable
is read."
Read the last sentence very carefully. After you call
InternetQueryDataAvailable(), you must read ALL available data before
you can call InternetQueryDataAvailable() again.
> my problem is not in reading the file
It may not be the original problem you were asking about, but it is
another problem in your code nontheless that you must address
properly.
> but in convincing the server in client's ability to accept that type
of file.
Had you read the RFC that I pointed you to, you would see that when a
406 reply is returned by the server, the reply data includes
alternative characteristics and locations that you must use to
download the content, as the original criteria you provided will not
work for what you are trying to download.
Gambit
Technical Details
Message-ID:
<459b0154$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.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> <459ac541$1@newsgroups.borland.com> <459acad3@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> <459ac541$1@newsgroups.borland.com> <459acad3@newsgroups.borland.com> Subject: Re: downloading with wininet Date: Tue, 2 Jan 2007 17:06:04 -0800 Lines: 58 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: <459b0154$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1167786324 75.83.34.171 (2 Jan 2007 17:05:24 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.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