=?UTF-8?Q?Michael=20M=C3=BCller=20?=: wininet: Handle INTERNET_INVALID_PORT_NUMBER in HttpOpenRequest.

Alexandre Julliard julliard at winehq.org
Thu Dec 15 16:58:32 CST 2016


Module: wine
Branch: master
Commit: 0d22e43f8c12fb6df92af2e05ac35cbdf1c3fe3f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0d22e43f8c12fb6df92af2e05ac35cbdf1c3fe3f

Author: Michael Müller <michael at fds-team.de>
Date:   Thu Dec 15 18:35:53 2016 +0100

wininet: Handle INTERNET_INVALID_PORT_NUMBER in HttpOpenRequest.

Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wininet/http.c       | 9 +++++++--
 dlls/wininet/tests/http.c | 6 +++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 658342b..1dffbaa 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3359,7 +3359,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");
 
@@ -3388,7 +3388,12 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
     request->session = session;
     list_add_head( &session->hdr.children, &request->hdr.entry );
 
-    request->server = get_server(substrz(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(substrz(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 9cda9c5..fb64e3c 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -6212,13 +6212,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);
@@ -6237,7 +6237,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);




More information about the wine-cvs mailing list