From: Daniel Lehman Subject: [PATCH] wininet: remove custom port handling in HTTP_HandleRedirect Message-Id: <2EE9C16F5A58104387BC411DC1EFA8F9BF8CE0D5@RED-INF-EXMB-P1.esri.com> Date: Wed, 22 Oct 2014 18:45:16 +0000 HTTP_HandleRedirect updates both: - the Host: field - and session->hostname If there is a custom port, it is appended to session->hostName. This causes problems for later HttpOpenRequest/process_host_port calls that append the port to the host name (resulting in "foobar:1234:1234") There is already logic in HTTP_HandleRequest that will update the request->server if the new host or port don't match. in that case, get_server/process_host_port use the updated host and port and store them appended in server->host_port. If they already match, server->host_port is left untouched The attached change removes the current custom port logic to instead use server->host_port to update the Host: field From 3744be8ccd9849800da41f8bbb3a6c5c616a48af Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Wed, 22 Oct 2014 10:53:58 -0700 Subject: [PATCH] wininet: remove custom port handling in HTTP_HandleRedirect --- dlls/wininet/http.c | 20 +++----------------- 1 files changed, 3 insertions(+), 17 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 4ef4534..44b05ff 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -3919,7 +3919,6 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) WCHAR protocol[INTERNET_MAX_SCHEME_LENGTH]; WCHAR hostName[INTERNET_MAX_HOST_NAME_LENGTH]; WCHAR userName[INTERNET_MAX_USER_NAME_LENGTH]; - BOOL custom_port = FALSE; static WCHAR httpW[] = {'h','t','t','p',0}; static WCHAR httpsW[] = {'h','t','t','p','s',0}; @@ -3953,8 +3952,6 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) if(urlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT; - else if(urlComponents.nPort != INTERNET_DEFAULT_HTTP_PORT) - custom_port = TRUE; }else if(!strcmpiW(protocol, httpsW)) { if(!(request->hdr.dwFlags & INTERNET_FLAG_SECURE)) { TRACE("redirect from non-secure page to secure page\n"); @@ -3964,26 +3961,13 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) if(urlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT; - else if(urlComponents.nPort != INTERNET_DEFAULT_HTTPS_PORT) - custom_port = TRUE; } heap_free(session->hostName); - if(custom_port) { - int len; - static const WCHAR fmt[] = {'%','s',':','%','u',0}; - len = lstrlenW(hostName); - len += 7; /* 5 for strlen("65535") + 1 for ":" + 1 for '\0' */ - session->hostName = heap_alloc(len*sizeof(WCHAR)); - sprintfW(session->hostName, fmt, hostName, urlComponents.nPort); - } - else - session->hostName = heap_strdupW(hostName); + session->hostName = heap_strdupW(hostName); session->hostPort = urlComponents.nPort; - HTTP_ProcessHeader(request, hostW, session->hostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); - heap_free(session->userName); session->userName = NULL; if (userName[0]) @@ -3998,6 +3982,8 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) server_release(request->server); request->server = new_server; } + + HTTP_ProcessHeader(request, hostW, request->server->host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); } heap_free(request->path); request->path=NULL; -- 1.6.0.4