From: "Hao Peng" Subject: [PATCH] wininet/test: Add tests on host value for InternetConnectW Message-Id: Date: Thu, 26 Nov 2015 19:08:02 +0800 overides patch 116912. 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 IE8 and above. Changed to using [www.winehq.org] for test; Added [todo_wine] in test. thanks Nikolay for comment, and Fracting for help. Signed-off-by: Hao Peng --- dlls/wininet/tests/http.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 5db930b..4b0e925 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -5769,6 +5769,91 @@ static void test_default_service_port(void) InternetCloseHandle(session); } +static void test_host_fill(void) +{ + HINTERNET session, connect, request; + DWORD error; + BOOL ret; + char statuscode[8] = {0}; + + session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(session != NULL, "InternetOpen failed\n"); + + connect = InternetConnectA(session, "www.winehq.org:21", INTERNET_DEFAULT_HTTPS_PORT, + NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + error = GetLastError(); + ok(connect != NULL, "InternetConnect failed\n"); + request = HttpOpenRequestA(connect, "GET", "/", "HTTP/1.1", NULL, NULL, + INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_SECURE | + INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_CERT_CN_INVALID, 0); + error = GetLastError(); + ok(request != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestA(request, NULL, 0, NULL, 0); + error = GetLastError(); + todo_wine { + ok(ret, "HttpSendRequest failed\n"); + ok(error == ERROR_FILE_NOT_FOUND /* IE8 */ || error == 0, "got %u\n", error); + } + + error = sizeof(statuscode); + SetLastError(0xdeadbeef); + ret = HttpQueryInfoA(request, HTTP_QUERY_STATUS_CODE, statuscode, &error, NULL); + error = atoi(statuscode); + ok(ret, "HttpQueryInfo failed\n"); + todo_wine ok(error == 200 /* IE8 */|| error == 400/* IE9 & above */, + "unknown failure, get %d\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + + connect = InternetConnectA(session, "www.winehq.org: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"); + todo_wine ok(error == ERROR_INTERNET_INVALID_URL, "got %u\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + + connect = InternetConnectA(session, "www.winehq.org:88", 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_NO_CACHE_WRITE | INTERNET_FLAG_NO_AUTO_REDIRECT, 0); + ok(request != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestA(request, NULL, 0, NULL, 0); + error = GetLastError(); + todo_wine { + ok(ret, "HttpSendRequest failed\n"); + ok(error == ERROR_FILE_NOT_FOUND /* IE8 */ || error == 0, "got %u\n", error); + } + + error = sizeof(statuscode); + SetLastError(0xdeadbeef); + ret = HttpQueryInfoA(request, HTTP_QUERY_STATUS_CODE, statuscode, &error, NULL); + error = atoi(statuscode); + ok(ret, "HttpQueryInfo failed\n"); + todo_wine ok(error == 302, "unknown failure, get %d\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + InternetCloseHandle(session); +} + static void init_status_tests(void) { memset(expect, 0, sizeof(expect)); @@ -5898,5 +5983,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(); }