Missing INTERNET_STATUS_REQUEST_COMPLETE callback after calling Wininet’s FtpOpenFile() in asynchronous mode



To reproduce the issue:

1.       Put a zero byte file on a FTP site.

2.       Call InternetOpen() with flag INTERNET_FLAG_ASYNC

3.       FtpOpenFile() to download the file.

Wininet will send out a FTP request. After receiving the response, the registered callback procedure will receive an INTERNET_STATUS_REQUEST_COMPLETE event.

4.       Call FtpOpenFile() again.

This time Wininet will not send out any FTP request, nor raise the INTERNET_STATUS_REQUEST_COMPLETE event.

The application will then hang if it waits for the above event.


This issue happens only if in asynchronous mode. A zero byte file can always reproduce the issue.




There is a Wininet asynchronous mode sample about how to download HTTP files: http://msdn.microsoft.com/en-us/library/cc185684(VS.85).aspx


Although it is HTTP not FTP, we can learn some ideas from that sample.




After test and test, it was found that if we add flag INTERNET_FLAG_RELOAD when calling FtpOpenFile(), it began to work properly.




According to http://msdn.microsoft.com/en-us/library/aa383661(VS.85).aspx :



Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. The FtpFindFirstFile, FtpGetFile, FtpOpenFile, FtpPutFile, HttpOpenRequest, and InternetOpenUrl functions use this flag.


Hope it helps!






Comments (0)

Skip to main content