cryptnet: Set timeout on http connections when a timeout is specified.

This commit is contained in:
Juan Lang 2007-10-23 12:50:29 -07:00 committed by Alexandre Julliard
parent cdca301821
commit 6c5f759d5a
1 changed files with 16 additions and 4 deletions

View File

@ -785,6 +785,14 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
if (hHttp)
{
if (dwTimeout)
{
InternetSetOptionW(hHttp,
INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeout,
sizeof(dwTimeout));
InternetSetOptionW(hHttp, INTERNET_OPTION_SEND_TIMEOUT,
&dwTimeout, sizeof(dwTimeout));
}
ret = HttpSendRequestExW(hHttp, NULL, NULL, 0,
(DWORD_PTR)context);
if (!ret && GetLastError() == ERROR_IO_PENDING)
@ -795,14 +803,18 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
else
ret = TRUE;
}
ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context);
if (!ret && GetLastError() == ERROR_IO_PENDING)
/* We don't set ret to TRUE in this block to avoid masking
* an error from HttpSendRequestExW.
*/
if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
GetLastError() == ERROR_IO_PENDING)
{
if (WaitForSingleObject(context->event,
context->timeout) == WAIT_TIMEOUT)
{
SetLastError(ERROR_TIMEOUT);
else
ret = TRUE;
ret = FALSE;
}
}
if (ret)
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,