Commit 6c5f759d authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

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

parent cdca3018
...@@ -785,6 +785,14 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL, ...@@ -785,6 +785,14 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
if (hHttp) 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, ret = HttpSendRequestExW(hHttp, NULL, NULL, 0,
(DWORD_PTR)context); (DWORD_PTR)context);
if (!ret && GetLastError() == ERROR_IO_PENDING) if (!ret && GetLastError() == ERROR_IO_PENDING)
...@@ -795,14 +803,18 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL, ...@@ -795,14 +803,18 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
else else
ret = TRUE; ret = TRUE;
} }
ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context); /* We don't set ret to TRUE in this block to avoid masking
if (!ret && GetLastError() == ERROR_IO_PENDING) * an error from HttpSendRequestExW.
*/
if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
GetLastError() == ERROR_IO_PENDING)
{ {
if (WaitForSingleObject(context->event, if (WaitForSingleObject(context->event,
context->timeout) == WAIT_TIMEOUT) context->timeout) == WAIT_TIMEOUT)
{
SetLastError(ERROR_TIMEOUT); SetLastError(ERROR_TIMEOUT);
else ret = FALSE;
ret = TRUE; }
} }
if (ret) if (ret)
ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp, ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment