Commit af3920dc authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Implement WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT.

parent 24279f1c
...@@ -1741,7 +1741,7 @@ static BOOL open_connection( request_t *request ) ...@@ -1741,7 +1741,7 @@ static BOOL open_connection( request_t *request )
return FALSE; return FALSE;
} }
netconn_set_timeout( netconn, TRUE, request->send_timeout ); netconn_set_timeout( netconn, TRUE, request->send_timeout );
netconn_set_timeout( netconn, FALSE, request->recv_timeout ); netconn_set_timeout( netconn, FALSE, request->receive_response_timeout );
if (is_secure) if (is_secure)
{ {
if (connect->session->proxy_server && if (connect->session->proxy_server &&
...@@ -1776,7 +1776,7 @@ static BOOL open_connection( request_t *request ) ...@@ -1776,7 +1776,7 @@ static BOOL open_connection( request_t *request )
TRACE("using connection %p\n", netconn); TRACE("using connection %p\n", netconn);
netconn_set_timeout( netconn, TRUE, request->send_timeout ); netconn_set_timeout( netconn, TRUE, request->send_timeout );
netconn_set_timeout( netconn, FALSE, request->recv_timeout ); netconn_set_timeout( netconn, FALSE, request->receive_response_timeout );
request->netconn = netconn; request->netconn = netconn;
} }
...@@ -2628,6 +2628,7 @@ static BOOL receive_response( request_t *request, BOOL async ) ...@@ -2628,6 +2628,7 @@ static BOOL receive_response( request_t *request, BOOL async )
BOOL ret; BOOL ret;
DWORD size, query, status; DWORD size, query, status;
netconn_set_timeout( request->netconn, FALSE, request->receive_response_timeout );
for (;;) for (;;)
{ {
if (!(ret = read_reply( request ))) if (!(ret = read_reply( request )))
...@@ -2665,6 +2666,7 @@ static BOOL receive_response( request_t *request, BOOL async ) ...@@ -2665,6 +2666,7 @@ static BOOL receive_response( request_t *request, BOOL async )
break; break;
} }
netconn_set_timeout( request->netconn, FALSE, request->receive_timeout );
if (request->content_length) refill_buffer( request, FALSE ); if (request->content_length) refill_buffer( request, FALSE );
if (async) if (async)
......
...@@ -1383,7 +1383,7 @@ static void test_set_default_proxy_config(void) ...@@ -1383,7 +1383,7 @@ static void test_set_default_proxy_config(void)
set_default_proxy_reg_value( saved_proxy_settings, len, type ); set_default_proxy_reg_value( saved_proxy_settings, len, type );
} }
static void test_Timeouts (void) static void test_timeouts(void)
{ {
BOOL ret; BOOL ret;
DWORD value, size; DWORD value, size;
...@@ -1972,6 +1972,70 @@ static void test_Timeouts (void) ...@@ -1972,6 +1972,70 @@ static void test_Timeouts (void)
ok(ret, "%u\n", GetLastError()); ok(ret, "%u\n", GetLastError());
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value); ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
/* response timeout */
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
ok(value == ~0u, "got %u\n", value);
SetLastError(0xdeadbeef);
value = 30000;
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
ok(value == ~0u, "got %u\n", value);
SetLastError(0xdeadbeef);
value = 30000;
ret = WinHttpSetOption(con, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, "got %u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
ok(value == ~0u, "got %u\n", value);
SetLastError(0xdeadbeef);
value = 48878;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 48879, "got %u\n", value);
SetLastError(0xdeadbeef);
value = 48880;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(value);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
ok(ret, "%u\n", GetLastError());
ok(value == 48880, "got %u\n", value);
WinHttpCloseHandle(req); WinHttpCloseHandle(req);
WinHttpCloseHandle(con); WinHttpCloseHandle(con);
WinHttpCloseHandle(ses); WinHttpCloseHandle(ses);
...@@ -4563,7 +4627,7 @@ START_TEST (winhttp) ...@@ -4563,7 +4627,7 @@ START_TEST (winhttp)
test_QueryOption(); test_QueryOption();
test_set_default_proxy_config(); test_set_default_proxy_config();
test_empty_headers_param(); test_empty_headers_param();
test_Timeouts(); test_timeouts();
test_resolve_timeout(); test_resolve_timeout();
test_credentials(); test_credentials();
test_IWinHttpRequest_Invoke(); test_IWinHttpRequest_Invoke();
......
...@@ -98,7 +98,8 @@ typedef struct ...@@ -98,7 +98,8 @@ typedef struct
int resolve_timeout; int resolve_timeout;
int connect_timeout; int connect_timeout;
int send_timeout; int send_timeout;
int recv_timeout; int receive_timeout;
int receive_response_timeout;
LPWSTR proxy_server; LPWSTR proxy_server;
LPWSTR proxy_bypass; LPWSTR proxy_bypass;
LPWSTR proxy_username; LPWSTR proxy_username;
...@@ -198,7 +199,8 @@ typedef struct ...@@ -198,7 +199,8 @@ typedef struct
int resolve_timeout; int resolve_timeout;
int connect_timeout; int connect_timeout;
int send_timeout; int send_timeout;
int recv_timeout; int receive_timeout;
int receive_response_timeout;
LPWSTR status_text; LPWSTR status_text;
DWORD content_length; /* total number of bytes to be read */ DWORD content_length; /* total number of bytes to be read */
DWORD content_read; /* bytes read so far */ DWORD content_read; /* bytes read so far */
......
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