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 ||
|
if (request->hdr.disable_flags & WINHTTP_DISABLE_REDIRECTS ||
|
||||||
request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_NEVER) break;
|
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;
|
if ((ret = handle_redirect( request, status ))) break;
|
||||||
|
|
||||||
/* recurse synchronously */
|
/* 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 );
|
str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
case WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS:
|
||||||
|
*(DWORD *)buffer = request->max_redirects;
|
||||||
|
*buflen = sizeof(DWORD);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("unimplemented option %u\n", option);
|
FIXME("unimplemented option %u\n", option);
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
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");
|
FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n");
|
||||||
return TRUE;
|
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:
|
default:
|
||||||
FIXME("unimplemented option %u\n", option);
|
FIXME("unimplemented option %u\n", option);
|
||||||
SetLastError( ERROR_WINHTTP_INVALID_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->send_timeout = connect->session->send_timeout;
|
||||||
request->receive_timeout = connect->session->receive_timeout;
|
request->receive_timeout = connect->session->receive_timeout;
|
||||||
request->receive_response_timeout = connect->session->receive_response_timeout;
|
request->receive_response_timeout = connect->session->receive_response_timeout;
|
||||||
|
request->max_redirects = 10;
|
||||||
|
|
||||||
if (!verb || !verb[0]) verb = L"GET";
|
if (!verb || !verb[0]) verb = L"GET";
|
||||||
if (!(request->verb = strdupW( verb ))) goto end;
|
if (!(request->verb = strdupW( verb ))) goto end;
|
||||||
|
|
|
@ -5102,7 +5102,7 @@ static void test_max_http_automatic_redirects (void)
|
||||||
|
|
||||||
max_redirects = 2;
|
max_redirects = 2;
|
||||||
ret = WinHttpSetOption(request, WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, &max_redirects, sizeof(max_redirects));
|
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);
|
ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
|
||||||
err = GetLastError();
|
err = GetLastError();
|
||||||
|
@ -5115,8 +5115,8 @@ static void test_max_http_automatic_redirects (void)
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = WinHttpReceiveResponse(request, NULL);
|
ret = WinHttpReceiveResponse(request, NULL);
|
||||||
todo_wine ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n");
|
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(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %u.\n", GetLastError());
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ret = WinHttpCloseHandle(request);
|
ret = WinHttpCloseHandle(request);
|
||||||
|
|
|
@ -189,6 +189,8 @@ struct request
|
||||||
int send_timeout;
|
int send_timeout;
|
||||||
int receive_timeout;
|
int receive_timeout;
|
||||||
int receive_response_timeout;
|
int receive_response_timeout;
|
||||||
|
DWORD max_redirects;
|
||||||
|
DWORD redirect_count; /* total number of redirects during this request */
|
||||||
WCHAR *status_text;
|
WCHAR *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 */
|
||||||
|
|
Loading…
Reference in New Issue