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:
HRESULT hRes = ::URLDownloadToFile( NULL, strTemp, strDestination, 0, pCallback );
strTemp gives the URL in the form:
https:////
pCallback is an implementation of IBindStatusCallback, IHttpSecurity, and IWindowForBindingUI.
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).
I get several calls in IBindStatusCallback::OnProgress, with this succession of ulStatus values:
BINDSTATUS_PROXYDETECTING BINDSTATUS_COOKIE_SENT BINDSTATUS_CONNECTING BINDSTATUS_SENDINGREQUEST
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.
I know that permission to write to the destination directory is not a problem.
I am not sure whether I am handling IBindStatusCallback::GetBindInfo and ::OnStartBinding correctly. Here is my code for each:
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;
}
Any ideas on what could be going wrong?