title: URLDownloadToFile fails with code 0x800c0008 (INET_E_DOWNLOAD_FAILURE)
body: <p>I'm trying to use URLDownloadToFile to download a file, but am getting INET_E_DOWNLOAD_FAILURE after the file is partially downloaded.  My call looks like:</p>
  
  <pre><code>HRESULT hRes = ::URLDownloadToFile( NULL, strTemp, strDestination, 0, pCallback );
  </code></pre>
  
  <p>strTemp gives the URL in the form:</p>
  
  <p>https:////</p>
  
  <p>pCallback is an implementation of IBindStatusCallback, IHttpSecurity, and IWindowForBindingUI.</p>
  
  <p>I am able to get to the point of having windows show a dialog warning me about the security certificate of the website (by returning S_FALSE in IHttpSecurity::OnSecurityProblem).  </p>
  
  <p>I get several calls in IBindStatusCallback::OnProgress, with this succession of ulStatus values:</p>
  
  <p>BINDSTATUS_PROXYDETECTING
  BINDSTATUS_COOKIE_SENT
  BINDSTATUS_CONNECTING
  BINDSTATUS_SENDINGREQUEST</p>
  
  <p>After that last OnProgress call, a packet sniffer shows that I get 100+ KB of data downloaded from the server (The file is 18+ MB.)  Then I get a call to IBindStatusCallback::OnStopBinding with an hResult value of INET_E_DOWNLOAD_FAILURE.</p>
  
  <p>I know that permission to write to the destination directory is not a problem.</p>
  
  <p>I am not sure whether I am handling IBindStatusCallback::GetBindInfo and ::OnStartBinding correctly.  Here is my code for each:</p>
  
  <pre><code>STDMETHODIMP CDownloadCallback::GetBindInfo( DWORD* pBINDF, BINDINFO* pBindinfo )
  {
     *pBINDF = BINDF_PULLDATA | BINDF_NOWRITECACHE | BINDF_GETNEWESTVERSION;
     return S_OK;
  }
  
  STDMETHODIMP CDownloadCallback::OnStartBinding( DWORD dwReserved, IBinding* pBinding )
  {
     return E_NOTIMPL;
  }
  </code></pre>
  
  <p>Any ideas on what could be going wrong?</p>