winhttp/tests: Fix tests when connecting via proxy.

This commit is contained in:
Greg Geldorp 2011-01-17 12:37:23 +01:00 committed by Alexandre Julliard
parent ac66c57523
commit 4745c567f5
1 changed files with 42 additions and 18 deletions

View File

@ -34,6 +34,25 @@ static const WCHAR test_useragent[] =
static const WCHAR test_server[] = {'w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
static BOOL proxy_active(void)
{
WINHTTP_PROXY_INFO proxy_info;
BOOL active = FALSE;
if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
{
active = (proxy_info.lpszProxy != NULL);
if (active)
GlobalFree((HGLOBAL) proxy_info.lpszProxy);
if (proxy_info.lpszProxyBypass != NULL)
GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
}
else
active = FALSE;
return active;
}
static void test_QueryOption(void)
{
BOOL ret;
@ -796,7 +815,7 @@ static void test_secure_connection(void)
ok(ret, "failed to send request %u\n", GetLastError());
ret = WinHttpReceiveResponse(req, NULL);
ok(!ret, "succeeded unexpectedly\n");
ok(!ret || proxy_active(), "succeeded unexpectedly\n");
size = 0;
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
@ -1668,6 +1687,8 @@ static void test_resolve_timeout(void)
DWORD timeout;
BOOL ret;
if (! proxy_active())
{
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
@ -1690,6 +1711,9 @@ static void test_resolve_timeout(void)
WinHttpCloseHandle(req);
WinHttpCloseHandle(con);
WinHttpCloseHandle(ses);
}
else
skip("Skipping host resolution tests, host resolution preformed by proxy\n");
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());