Module: wine Branch: master Commit: 6a609c21bbee8287b2ee6d027013855843106a43 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6a609c21bbee8287b2ee6d0270...
Author: Hans Leidekker hans@codeweavers.com Date: Wed Mar 6 13:30:49 2013 +0100
wininet: Port resolution doesn't depend on the secure flag.
---
dlls/wininet/http.c | 19 +++++++++++-------- dlls/wininet/tests/http.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 468fee6..8fec2a4 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -283,7 +283,7 @@ server_t *get_server(const WCHAR *name, INTERNET_PORT port, BOOL is_https, BOOL server_t *iter, *server = NULL;
if(port == INTERNET_INVALID_PORT_NUMBER) - port = is_https ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT; + port = INTERNET_DEFAULT_HTTP_PORT;
EnterCriticalSection(&connection_pool_cs);
@@ -1706,6 +1706,9 @@ static WCHAR *build_proxy_path_url(http_request_t *req) */ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_request_t *request) { + static const WCHAR protoHttp[] = { 'h','t','t','p',0 }; + static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 }; + static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',0 }; WCHAR buf[INTERNET_MAX_HOST_NAME_LENGTH]; WCHAR protoProxy[INTERNET_MAX_URL_LENGTH]; DWORD protoProxyLen = INTERNET_MAX_URL_LENGTH; @@ -1713,9 +1716,7 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req static WCHAR szNul[] = { 0 }; URL_COMPONENTSW UrlComponents; server_t *new_server; - static const WCHAR protoHttp[] = { 'h','t','t','p',0 }; - static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 }; - static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',0 }; + BOOL is_https;
memset( &UrlComponents, 0, sizeof UrlComponents ); UrlComponents.dwStructSize = sizeof UrlComponents; @@ -1737,7 +1738,11 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req if( !request->path ) request->path = szNul;
- new_server = get_server(UrlComponents.lpszHostName, UrlComponents.nPort, UrlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE); + is_https = (UrlComponents.nScheme == INTERNET_SCHEME_HTTPS); + if (is_https && UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) + UrlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT; + + new_server = get_server(UrlComponents.lpszHostName, UrlComponents.nPort, is_https, TRUE); if(!new_server) return FALSE;
@@ -3160,9 +3165,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, HTTP_ProcessHeader(request, hostW, request->server->canon_host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
if (session->hostPort == INTERNET_INVALID_PORT_NUMBER) - session->hostPort = (dwFlags & INTERNET_FLAG_SECURE ? - INTERNET_DEFAULT_HTTPS_PORT : - INTERNET_DEFAULT_HTTP_PORT); + session->hostPort = INTERNET_DEFAULT_HTTP_PORT;
if (hIC->proxy && hIC->proxy[0]) HTTP_DealWithProxy( hIC, session, request ); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 5f7a961..c682930 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -4013,6 +4013,34 @@ static void test_connection_failure(void) InternetCloseHandle(session); }
+static void test_default_service_port(void) +{ + HINTERNET session, connect, request; + DWORD error; + BOOL ret; + + session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(session != NULL, "InternetOpen failed\n"); + + connect = InternetConnect(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL, + INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); + + request = HttpOpenRequest(connect, NULL, "/", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0); + ok(request != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequest(request, NULL, 0, NULL, 0); + error = GetLastError(); + ok(!ret, "HttpSendRequest succeeded\n"); + ok(error == ERROR_INTERNET_SECURITY_CHANNEL_ERROR || error == ERROR_INTERNET_CANNOT_CONNECT, + "got %u\n", error); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + InternetCloseHandle(session); +} + static void init_status_tests(void) { memset(expect, 0, sizeof(expect)); @@ -4091,4 +4119,5 @@ START_TEST(http) HttpSendRequestEx_test(); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]); test_connection_failure(); + test_default_service_port(); }