[6/6] wininet: Handle INTERNET_INVALID_PORT_NUMBER in HttpOpenRequest.

Sebastian Lackner sebastian at fds-team.de
Mon Apr 25 14:46:29 CDT 2016


From: Michael Müller <michael at fds-team.de>

Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/wininet/http.c       |   11 +++++++++--
 dlls/wininet/tests/http.c |    6 +++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 6c2c567..92fec5e 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3362,7 +3362,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
 {
     appinfo_t *hIC = session->appInfo;
     http_request_t *request;
-    DWORD len;
+    DWORD port, len;
 
     TRACE("-->\n");
 
@@ -3391,7 +3391,14 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
     request->session = session;
     list_add_head( &session->hdr.children, &request->hdr.entry );
 
-    request->server = get_server(session->hostName, session->hostPort, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE);
+    port = session->hostPort;
+    if (port == INTERNET_INVALID_PORT_NUMBER)
+    {
+        port = (session->hdr.dwFlags & INTERNET_FLAG_SECURE) ?
+                INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;
+    }
+
+    request->server = get_server(session->hostName, port, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE);
     if(!request->server) {
         WININET_Release(&request->hdr);
         return ERROR_OUTOFMEMORY;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 69453dc..ded33c7 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -5948,13 +5948,13 @@ static void test_default_service_port(void)
     ok(request != NULL, "HttpOpenRequest failed\n");
 
     ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
-    todo_wine ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
+    ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
 
     size = sizeof(buffer);
     memset(buffer, 0, sizeof(buffer));
     ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
     ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
-    todo_wine ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got '%s'\n", buffer);
+    ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got '%s'\n", buffer);
 
     InternetCloseHandle(request);
     InternetCloseHandle(connect);
@@ -5973,7 +5973,7 @@ static void test_default_service_port(void)
     memset(buffer, 0, sizeof(buffer));
     ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
     ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
-    todo_wine ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got '%s'\n", buffer);
+    ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got '%s'\n", buffer);
 
     InternetCloseHandle(request);
     InternetCloseHandle(connect);
-- 
2.7.1



More information about the wine-patches mailing list