A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
I need a WinInet expert to help explain why my InternetReadFile API calls works - but only sometimes.
I do the following:
1) InternetOpen, InternetCloseHandle in the contrustor/destructor to create some sort of internet agent.
2) For each file in my batch I do:
* InternetOpenUrl to get handle to the file
* I loop over the file with InternetReadFile while return size is >0.
In most of my tests, the files I download are fine. However, every so often, a file that should be (say) 100K is only downloaded at 20K. Debugging does not find any errors with the APIs, and infact the InternetReadFile truly does succeed and return 0 bytes before the full file is retrieved.
Saturday, January 01, 2005
The obvious answer is that you should only stop once you
get given a return size of zero AND the function returns TRUE.
Sorry I meant to add that you may be doing this already, other than that I have no idea.
Indeed I am stopping when return size is 0 and function returns completion value (actually, function returns true when 0 or non-0)
Sunday, January 02, 2005
Bugger, worth a try.
(don't know if this is still true).
or just make your life easier and use the xmlhttp object if you can.
Thanks for the URL. It looks great, except that after rebooting my computer again and making some changes to the files on the server, the problem no longer appears. This leads me to think that there is some sort of issue with caching of data (I also cleaned my IE/FireFox caches). I am trying to use as many flags as possible with InternetOpenUrl to avoid problems. Any recommendations regarding the flags that I use, as shown here:
Monday, January 03, 2005
check the result to see if it tells you something about the cache (http 304 status? magic flag?)... though i don't know (or perhaps remember) how. there's definately a way to pull a file from the cache, i once wrote a cache-scrounging program to try to recover cached files from a hosed server.
though really i'd expect wininet to abstact the cache for you.
It's been a long time since I used WinInet, but I do seem to remember having similar problems, which were fixed by specifying the flag INTERNET_FLAG_DONT_CACHE in the InternetOpen call
Monday, January 03, 2005
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz