From: Daniel Lehman Subject: [PATCH] wininet: remove custom port handling in HTTP_HandleRedirect (try 3) Message-Id: <2EE9C16F5A58104387BC411DC1EFA8F9BF8D82FD@RED-INF-EXMB-P1.esri.com> Date: Fri, 24 Oct 2014 23:16:15 +0000 Try 3: - changed patch subject to more accurately reflect the point of the patch - fix wine test. I was blindly replacing the Host field with the appended host_port, which is only needed if a custom port is used 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 (and updated) change replaces the Host field with the combined host_port if a custom port is used, or just the server name for a standard port From 47bea065951ace65407cb311c5ec230da9f4a0dd Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Fri, 24 Oct 2014 07:43:00 -0700 Subject: [PATCH] wininet: don't append custom port to session host name --- dlls/wininet/http.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 40f8d9a..a98ed53 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -4173,20 +4173,9 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) 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 +4190,11 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) server_release(request->server); request->server = new_server; } + + if (custom_port) + HTTP_ProcessHeader(request, hostW, request->server->host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); + else + HTTP_ProcessHeader(request, hostW, request->server->name, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); } heap_free(request->path); request->path=NULL; -- 1.7.12.3