InternetOpenUrl returns only after loading the entire HTTP response

I am writing a download file utility using WinINET, and noticed (especially with large downloads) that the WinINET call InternetOpenUrl()returns only after the entire HTTP response has been downloaded.

I confirmed this using the Charles proxy tool, as well as using WireShark and noticed that the download was completely completed, and only then WinINET notifies my code.

Some simplified (synchronous) codes:

hInt = InternetOpen(USER_AGENT_NAME, INTERNET_OPEN_TYPE_PRECONFIG, 
                    NULL, NULL, 0);
DWORD dwRequestFlags = INTERNET_FLAG_NO_UI   // no UI please
            |INTERNET_FLAG_NO_AUTH           // don't authenticate
            |INTERNET_FLAG_PRAGMA_NOCACHE    // do not try the cache or proxy
            |INTERNET_FLAG_NO_CACHE_WRITE;   // don't add this to the IE cache

hUrl = InternetOpenUrl(hInt, szURL, NULL, 0, dwRequestFlags, NULL);
if (hUrl)
{
  // <only gets here after entire download is complete>

  InternetCloseHandle(hUrl);
}
InternetCloseHandle(hInt);

The documentation assumes that this sends the request and processes the response headers (does not complete the download), and then you must go through the loop InternetReadFile()until it returns TRUEand dwNumberOfBytesRead. 0.

MSDN
InternetOpenUrl: InternetOpenUrl URL, , , URL-. InternetReadFile [...] URL.

InternetReadFile: , InternetReadFile , TRUE, lpdwNumberOfBytesRead .

, , . , INTERNET_STATUS_RESPONSE_RECEIVED . , .

, WinHttp, .

, -. - ( 30 ), InternetOpenUrl() .

:

WinInet WinHttp, InternetReadFile(), ( WinINET )?

, , 150 , , , ... WinINET .

, recv(), , IE (, , )?

? , , , -?

, , ?

, . Berkley HTTP, recv(), , .

, , HTTP SSL, WinINET.

+5
1

, , , , , , , .

( , , , ) , Alex K. J.J. , , , , , .

, , , , , , .

" ", hey-presto, InternetOpenUrl 2 HTTP-. , 75- , , WinINET , .

, , InternetReadFile(), ( ), (), InternetReadFile() recv() ( ).

. - ( ) .

, , (: -) , -, .

+12

All Articles