From: "Hao Peng" Subject: [PATCH] add test on host value of InternetConnectW Message-Id: Date: Tue, 24 Nov 2015 21:02:39 +0800 Add a test on giving host value of InternetConnectionW. Some App fill host param with port number when calling InternetConnectionW. it will still operate successfull on system brove windows 2000. I tested to connect to [www.winehq.org], but I got GetLastError with 2 on WinXP and Win2003, other systems were fine. (See https://testbot.winehq.org/JobDetails.pl?Key=18484) All fine when I tested to connecting to [www.bing.com]. (https://testbot.winehq.org/JobDetails.pl?Key=18482) And I didn't get what happened. I plan to send a patch to fix this later. Any comments are welcome. Signed-off-by: Hao Peng --- dlls/wininet/tests/http.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 5db930b..c1970ef 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -5769,6 +5769,54 @@ static void test_default_service_port(void) InternetCloseHandle(session); } +static void test_host_fill(void) +{ + HINTERNET session, connect, request; + DWORD error; + BOOL ret; + + session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(session != NULL, "InternetOpen failed\n"); + + connect = InternetConnectA(session, "www.bing.com:21", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, + INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); + + request = HttpOpenRequestA(connect, "GET", "/", "HTTP/1.1", NULL, NULL, + INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_CACHE_WRITE | + INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_CERT_CN_INVALID, 0); + ok(request != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestA(request, NULL, 0, NULL, 0); + error = GetLastError(); + ok(ret || broken(!ret /* win2000 */), "HttpSendRequest failed\n"); + ok(error == 0 || broken(error == ERROR_INTERNET_NAME_NOT_RESOLVED /* win2000 */), "got %u\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + + connect = InternetConnectA(session, "www.bing.com:443", 0, NULL, NULL, + INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); + + request = HttpOpenRequestA(connect, "GET", "/", "HTTP/1.1", NULL, NULL, + INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_CACHE_WRITE | + INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_CERT_CN_INVALID, 0); + ok(request != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestA(request, NULL, 0, NULL, 0); + error = GetLastError(); + ok(!ret, "HttpSendRequest should fail\n"); + ok(error == ERROR_INTERNET_INVALID_URL || broken(error == ERROR_INTERNET_NAME_NOT_RESOLVED /* win2000 */), + "got %u\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + InternetCloseHandle(session); +} + static void init_status_tests(void) { memset(expect, 0, sizeof(expect)); @@ -5898,5 +5946,6 @@ START_TEST(http) InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]); test_connection_failure(); test_default_service_port(); + test_host_fill(); test_concurrent_header_access(); }