winhttp: Implement WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS.
Signed-off-by: Owen Rudge <orudge@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e4e94ed72e
commit
5042687d01
|
@ -2720,6 +2720,8 @@ static DWORD receive_response( struct request *request, BOOL async )
|
|||
if (request->hdr.disable_flags & WINHTTP_DISABLE_REDIRECTS ||
|
||||
request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_NEVER) break;
|
||||
|
||||
if (++request->redirect_count > request->max_redirects) return ERROR_WINHTTP_REDIRECT_FAILED;
|
||||
|
||||
if ((ret = handle_redirect( request, status ))) break;
|
||||
|
||||
/* recurse synchronously */
|
||||
|
|
|
@ -820,6 +820,11 @@ static BOOL request_query_option( struct object_header *hdr, DWORD option, void
|
|||
str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
|
||||
return TRUE;
|
||||
|
||||
case WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS:
|
||||
*(DWORD *)buffer = request->max_redirects;
|
||||
*buflen = sizeof(DWORD);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
FIXME("unimplemented option %u\n", option);
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
|
@ -1028,6 +1033,17 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b
|
|||
FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n");
|
||||
return TRUE;
|
||||
|
||||
case WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS:
|
||||
if (buflen == sizeof(DWORD))
|
||||
{
|
||||
request->max_redirects = *(DWORD *)buffer;
|
||||
SetLastError(NO_ERROR);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
FIXME("unimplemented option %u\n", option);
|
||||
SetLastError( ERROR_WINHTTP_INVALID_OPTION );
|
||||
|
@ -1121,6 +1137,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
|
|||
request->send_timeout = connect->session->send_timeout;
|
||||
request->receive_timeout = connect->session->receive_timeout;
|
||||
request->receive_response_timeout = connect->session->receive_response_timeout;
|
||||
request->max_redirects = 10;
|
||||
|
||||
if (!verb || !verb[0]) verb = L"GET";
|
||||
if (!(request->verb = strdupW( verb ))) goto end;
|
||||
|
|
|
@ -5102,7 +5102,7 @@ static void test_max_http_automatic_redirects (void)
|
|||
|
||||
max_redirects = 2;
|
||||
ret = WinHttpSetOption(request, WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, &max_redirects, sizeof(max_redirects));
|
||||
todo_wine ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
|
||||
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
|
||||
|
||||
ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
|
||||
err = GetLastError();
|
||||
|
@ -5115,8 +5115,8 @@ static void test_max_http_automatic_redirects (void)
|
|||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = WinHttpReceiveResponse(request, NULL);
|
||||
todo_wine ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n");
|
||||
todo_wine ok(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %u.\n", GetLastError());
|
||||
ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n");
|
||||
ok(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %u.\n", GetLastError());
|
||||
|
||||
done:
|
||||
ret = WinHttpCloseHandle(request);
|
||||
|
|
|
@ -189,6 +189,8 @@ struct request
|
|||
int send_timeout;
|
||||
int receive_timeout;
|
||||
int receive_response_timeout;
|
||||
DWORD max_redirects;
|
||||
DWORD redirect_count; /* total number of redirects during this request */
|
||||
WCHAR *status_text;
|
||||
DWORD content_length; /* total number of bytes to be read */
|
||||
DWORD content_read; /* bytes read so far */
|
||||
|
|
Loading…
Reference in New Issue