wininet: Implement setting of send and receive timeouts.

This commit is contained in:
Robert Shearman 2006-03-14 14:36:11 +00:00 committed by Alexandre Julliard
parent ea6f3a4cc0
commit 5b5d45586e
3 changed files with 51 additions and 4 deletions

View File

@ -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");

View File

@ -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);

View File

@ -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;
}