title: InternetReadFile() reads data but returns false and sets number of bytes read to zero
body: <p>Making an asynchronous request with Wininet, when the status callback function is called with INTERNET_STATUS_REQUEST_COMPLETE, I get the http status code.</p>
  
  <pre><code>result = HttpQueryInfo(
      this-&gt;requestHandle,
      HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
      &amp;value,
      &amp;sizeofDword,
      &amp;index);
  </code></pre>
  
  <p>The status code returned is 200. After that, I call InternetReadFile(). </p>
  
  <pre><code>result = InternetReadFile(
      this-&gt;requestHandle,
      ((char*)(this-&gt;buffer)) + this-&gt;totalBytesReceived,
      this-&gt;bufferSize - this-&gt;totalBytesReceived,
      &amp;bytesRead);
  
  this-&gt;totalBytesReceived += bytesRead;
  </code></pre>
  
  <p>It returns true and sets lpNumberOfBytesRead to zero. GetLastError() returns ERROR_IO_PENDING, then I wait the callback function is called again with INTERNET_STATUS_REQUEST_COMPLETE. </p>
  
  <p>When that occurs, InternetReadFile() returns true and again sets lpNumberOfBytesRead to zero.</p>
  
  <p>If I debug the application, I can see after the first InternetReadFile() that the response data is already on the lpBuffer. Moreover, if I call Sleep() for one second before InternetReadFile(), InternetReadFile() works correctly.</p>
  
  <pre><code>Sleep(1000);
  
  result = InternetReadFile( ...
  </code></pre>
  
  <p>Am I missing any step? </p>