From: Daniel Lehman Subject: [PATCH] wininet: remove custom port handling in HTTP_HandleRedirect (try 2) Message-Id: <2EE9C16F5A58104387BC411DC1EFA8F9BF8CFCA8@RED-INF-EXMB-P1.esri.com> Date: Thu, 23 Oct 2014 14:21:54 +0000 Try 2: rebased 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 6c708cb6c9f23819e9c7c68a4840e286a9948dfe 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 file changed, 3 insertions(+), 17 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 40f8d9a..e45278c 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -4122,7 +4122,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 const WCHAR httpW[] = {'h','t','t','p',0}; static const WCHAR httpsW[] = {'h','t','t','p','s',0}; @@ -4156,8 +4155,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"); @@ -4167,26 +4164,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]) @@ -4201,6 +4185,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.7.12.3