Commit 5b5d4558 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

wininet: Implement setting of send and receive timeouts.

parent ea6f3a4c
......@@ -2442,11 +2442,29 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
case INTERNET_OPTION_DISABLE_PASSPORT_AUTH:
TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
break;
case INTERNET_OPTION_RECEIVE_TIMEOUT:
FIXME("Option INTERNET_OPTION_RECEIVE_TIMEOUT: STUB\n");
break;
case INTERNET_OPTION_SEND_TIMEOUT:
FIXME("Option INTERNET_OPTION_SEND_TIMEOUT: STUB\n");
case INTERNET_OPTION_RECEIVE_TIMEOUT:
TRACE("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT\n");
if (dwBufferLength == sizeof(DWORD))
{
if (lpwhh->htype == WH_HHTTPREQ)
ret = NETCON_set_timeout(
&((LPWININETHTTPREQW)lpwhh)->netConnection,
dwOption == INTERNET_OPTION_SEND_TIMEOUT,
*(DWORD *)lpBuffer);
else
{
FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT not supported on protocol %d\n",
lpwhh->htype);
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
ret = FALSE;
}
}
else
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
ret = FALSE;
}
break;
case INTERNET_OPTION_CONNECT_RETRIES:
FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
......
......@@ -481,6 +481,7 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
int *recvd /* out */);
BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
extern void URLCacheContainers_CreateDefaults(void);
extern void URLCacheContainers_DeleteAll(void);
......
......@@ -714,3 +714,31 @@ LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection)
return NULL;
#endif
}
BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value)
{
int result;
struct timeval tv;
/* FIXME: we should probably store the timeout in the connection to set
* when we do connect */
if (!NETCON_connected(connection))
return TRUE;
/* value is in milliseconds, convert to struct timeval */
tv.tv_sec = value / 1000;
tv.tv_usec = (value % 1000) * 1000;
result = setsockopt(connection->socketFD, SOL_SOCKET,
send ? SO_SNDTIMEO : SO_RCVTIMEO, &tv,
sizeof(tv));
if (result == -1)
{
WARN("setsockopt failed (%s)\n", strerror(errno));
INTERNET_SetLastError(sock_get_error(errno));
return FALSE;
}
return TRUE;
}
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