From: "Hao Peng" Subject: [PATCH] wininet/test: Add tests on host value for InternetConnectW (try 3) Message-Id: Date: Thu, 26 Nov 2015 20:38:13 +0800 overides patch 116912 and 116968. Add a test on giving host value of InternetConnectW. Some App fill host param with port number when calling InternetConnectionW. it would still operate successfull on IE8 and above(responses for these requests may mot be right). But they would fail in wine because failures of Domain resolving. On windows, domain resolving will ingore the port in the host value, but these host value havng port number will been send in HTTP protocol; Wininet will only use the port parameter to connect to the server, no matter what filled in the host param. CHANGES: use [www.winehq.org] & [test.winehq.org] for test; Added [todo_wine] in test; Removed unused GetLastError. thanks Nikolay for comment, and Fracting for help. Signed-off-by: Hao Peng --- dlls/wininet/tests/http.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) overides patch 116912 and 116968.

Add a test on giving host value of InternetConnectW.
Some App fill host param with port number when calling InternetConnectionW. it would still operate successfull on IE8 and above
(responses for these requests may mot be right). But they would fail in wine because failures of Domain resolving.

On windows, domain resolving will ingore the port in the host value, but these host value havng port number will been send in 
HTTP protocol; Wininet will only use the port parameter to connect to the server, no matter what filled in the host param.

CHANGES:
use [www.winehq.org] & [test.winehq.org] for test;
Added [todo_wine] in test;
Removed unused GetLastError.

thanks Nikolay for comment, and Fracting for help.

Signed-off-by: Hao Peng <penghao@linuxdeepin.com>
---
 dlls/wininet/tests/http.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)


diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 5db930b..a418bf4 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -5769,6 +5769,90 @@ 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); + 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); + 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, "test.winehq.org:12345", 0, + NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); + + request = HttpOpenRequestA(connect, "GET", "/data/", "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 == 200, "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 +5982,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(); }