From 1d811fbe792928c28a9dbfa2fd82fdbb5b92bdc1 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 22 Nov 2015 10:15:42 +0000 Subject: [PATCH] [WININET_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536 svn path=/trunk/; revision=70010 --- rostests/winetests/wininet/http.c | 51 ++++++++++++++++++++------ rostests/winetests/wininet/internet.c | 53 ++++++++++++++++++++++++--- rostests/winetests/wininet/urlcache.c | 2 +- 3 files changed, 89 insertions(+), 17 deletions(-) diff --git a/rostests/winetests/wininet/http.c b/rostests/winetests/wininet/http.c index 077172c8931..02c74fe8d12 100644 --- a/rostests/winetests/wininet/http.c +++ b/rostests/winetests/wininet/http.c @@ -2127,6 +2127,13 @@ static DWORD CALLBACK server_thread(LPVOID param) else send(c, notokmsg, sizeof notokmsg-1, 0); } + if (strstr(buffer, "CONNECT ")) + { + if (!strstr(buffer, "Content-Length: 0")) + send(c, notokmsg, sizeof notokmsg-1, 0); + else + send(c, proxymsg, sizeof proxymsg-1, 0); + } if (strstr(buffer, "/test2")) { if (strstr(buffer, "Proxy-Authorization: Basic bWlrZToxMTAx")) @@ -2174,6 +2181,8 @@ static DWORD CALLBACK server_thread(LPVOID param) { if (strstr(buffer, "Content-Length: 100")) { + if (strstr(buffer, "POST /test7b")) + recvfrom(c, buffer, sizeof buffer, 0, NULL, NULL); send(c, okmsg, sizeof okmsg-1, 0); send(c, page1, sizeof page1-1, 0); } @@ -2490,7 +2499,7 @@ static void test_proxy_indirect(int port) DWORD r, sz; char buffer[0x40]; - hi = InternetOpenA(NULL, 0, NULL, NULL, 0); + hi = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); ok(hi != NULL, "open failed\n"); hc = InternetConnectA(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); @@ -2884,6 +2893,25 @@ static void test_proxy_direct(int port) ok(r, "HttpQueryInfo failed\n"); ok(!strcmp(buffer, "200"), "proxy code wrong\n"); + InternetCloseHandle(hr); + InternetCloseHandle(hc); + InternetCloseHandle(hi); + + sprintf(buffer, "localhost:%d\n", port); + hi = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0); + ok(hi != NULL, "InternetOpen failed\n"); + + hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(hc != NULL, "InternetConnect failed\n"); + + hr = HttpOpenRequestA(hc, "POST", "/test2", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0); + ok(hr != NULL, "HttpOpenRequest failed\n"); + + r = HttpSendRequestA(hr, NULL, 0, (char *)"data", sizeof("data")); + ok(r, "HttpSendRequest failed %u\n", GetLastError()); + + test_status_code(hr, 407); + done: InternetCloseHandle(hr); InternetCloseHandle(hc); @@ -2959,7 +2987,7 @@ static void test_header_handling_order(int port) connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); ok(connect != NULL, "InternetConnect failed\n"); - request = HttpOpenRequestA(connect, "POST", "/test7b", NULL, NULL, types, 0, 0); + request = HttpOpenRequestA(connect, "POST", "/test7b", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0); ok(request != NULL, "HttpOpenRequest failed\n"); ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW); @@ -2967,8 +2995,8 @@ static void test_header_handling_order(int port) data_len = sizeof(data); memset(data, 'a', sizeof(data)); - ret = HttpSendRequestA(request, connection, ~0u, data, data_len); - ok(ret, "HttpSendRequest failed\n"); + ret = HttpSendRequestA(request, NULL, 0, data, data_len); + ok(ret, "HttpSendRequest failed: %u\n", GetLastError()); status = 0; size = sizeof(status); @@ -3526,7 +3554,7 @@ static void test_no_content(int port) hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - session = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC); + session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); pInternetSetStatusCallbackA(session, callback); @@ -3591,7 +3619,7 @@ static void test_conn_close(int port) hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); conn_close_event = CreateEventW(NULL, FALSE, FALSE, NULL); - session = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC); + session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); pInternetSetStatusCallbackA(session, callback); @@ -4602,7 +4630,7 @@ static void test_accept_encoding(int port) HINTERNET ses, con, req; BOOL ret; - ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); ok(ses != NULL, "InternetOpen failed\n"); con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); @@ -4640,7 +4668,7 @@ static void test_basic_auth_credentials_reuse(int port) DWORD status, size; BOOL ret; - ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 ); + ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 ); ok( ses != NULL, "InternetOpenA failed\n" ); con = InternetConnectA( ses, "localhost", port, "user", "pwd", @@ -4663,7 +4691,7 @@ static void test_basic_auth_credentials_reuse(int port) InternetCloseHandle( con ); InternetCloseHandle( ses ); - ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 ); + ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 ); ok( ses != NULL, "InternetOpenA failed\n" ); con = InternetConnectA( ses, "localhost", port, NULL, NULL, @@ -4832,7 +4860,7 @@ static void _test_security_info(unsigned line, const char *urlc, DWORD error, DW CertFreeCertificateChain(chain); }else { ok_(__FILE__,line)(!res && GetLastError() == error, - "InternetGetSecurityInfoByURLA returned: %x(%u), exected %u\n", res, GetLastError(), error); + "InternetGetSecurityInfoByURLA returned: %x(%u), expected %u\n", res, GetLastError(), error); } } @@ -5902,6 +5930,7 @@ static void test_async_HttpSendRequestEx(const struct notification_data *nd) WaitForSingleObject( info.wait, 10000 ); Sleep(100); CloseHandle( info.wait ); + DeleteCriticalSection( ¬ification_cs ); } static HINTERNET closetest_session, closetest_req, closetest_conn; @@ -5976,7 +6005,7 @@ static void test_connection_failure(void) DWORD error; BOOL ret; - session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); ok(session != NULL, "failed to get session handle\n"); connect = InternetConnectA(session, "localhost", 1, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); diff --git a/rostests/winetests/wininet/internet.c b/rostests/winetests/wininet/internet.c index 5adecd7f819..d19bc945d70 100644 --- a/rostests/winetests/wininet/internet.c +++ b/rostests/winetests/wininet/internet.c @@ -1112,31 +1112,45 @@ static void test_InternetSetOption(void) SetLastError(0xdeadbeef); ulArg = 11; ret = InternetSetOptionA(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG)); - ok(ret == FALSE, "InternetQueryOption should've failed\n"); + ok(ret == FALSE, "InternetSetOption should've failed\n"); ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError()); SetLastError(0xdeadbeef); ulArg = 11; ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20); - ok(ret == FALSE, "InternetQueryOption should've failed\n"); + ok(ret == FALSE, "InternetSetOption should've failed\n"); ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError()); ulArg = 11; ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG)); - ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); SetLastError(0xdeadbeef); ulArg = 4; ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG)); - ok(ret == FALSE, "InternetQueryOption should've failed\n"); + ok(ret == FALSE, "InternetSetOption should've failed\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError()); SetLastError(0xdeadbeef); ulArg = 16; ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG)); - ok(ret == FALSE, "InternetQueryOption should've failed\n"); + ok(ret == FALSE, "InternetSetOption should've failed\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError()); + ret = InternetSetOptionA(req, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); + + ret = InternetSetOptionA(ses, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); + + ret = InternetSetOptionA(ses, INTERNET_OPTION_REFRESH, NULL, 0); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); + + SetLastError(0xdeadbeef); + ret = InternetSetOptionA(req, INTERNET_OPTION_REFRESH, NULL, 0); + todo_wine ok(ret == FALSE, "InternetSetOption should've failed\n"); + todo_wine ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError()); + ret = InternetCloseHandle(req); ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError()); ret = InternetCloseHandle(con); @@ -1350,6 +1364,35 @@ static void test_Option_PerConnectionOptionA(void) HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue); HeapFree(GetProcessHeap(), 0, list.pOptions); + /* test with NULL as proxy server */ + list.dwOptionCount = 1; + list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA)); + list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; + list.pOptions[0].Value.pszValue = NULL; + + ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); + + ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); + ok(ret == TRUE, "InternetSetOption should've succeeded\n"); + + HeapFree(GetProcessHeap(), 0, list.pOptions); + + /* get & verify the proxy server */ + list.dwOptionCount = 1; + list.dwOptionError = 0; + list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA)); + list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; + + ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); + ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); + ok(!list.pOptions[0].Value.pszValue, + "Retrieved proxy server should've been NULL, was: \"%s\"\n", + list.pOptions[0].Value.pszValue); + + HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue); + HeapFree(GetProcessHeap(), 0, list.pOptions); + /* restore original settings */ list.dwOptionCount = 2; list.pOptions = orig_settings; diff --git a/rostests/winetests/wininet/urlcache.c b/rostests/winetests/wininet/urlcache.c index aadc2b9f0ed..afeda9d269d 100644 --- a/rostests/winetests/wininet/urlcache.c +++ b/rostests/winetests/wininet/urlcache.c @@ -1090,7 +1090,7 @@ static void test_trailing_slash(void) ret = CreateUrlCacheEntryA(url_with_slash, 0, "html", filename, 0); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); - create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); + create_and_write_file(filename, &zero_byte, sizeof(zero_byte)); ret = CommitUrlCacheEntryA("Visited: http://testing.cache.com/", NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);