Commit 7bb34631 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Add a new field "lpszHostName" to the session to track the host name

of the HTTP server, as opposed to the server that we will connect to that could be a proxy server. Fixes the "Host:" header that we send to servers.
parent 7ec69e9c
...@@ -933,15 +933,15 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC, ...@@ -933,15 +933,15 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC,
if( !lpwhr->lpszPath ) if( !lpwhr->lpszPath )
lpwhr->lpszPath = (LPWSTR)szNul; lpwhr->lpszPath = (LPWSTR)szNul;
TRACE("server='%s' path='%s'\n", TRACE("server='%s' path='%s'\n",
debugstr_w(lpwhs->lpszServerName), debugstr_w(lpwhr->lpszPath)); debugstr_w(lpwhs->lpszHostName), debugstr_w(lpwhr->lpszPath));
/* for constant 15 see above */ /* for constant 15 see above */
len = strlenW(lpwhs->lpszServerName) + strlenW(lpwhr->lpszPath) + 15; len = strlenW(lpwhs->lpszHostName) + strlenW(lpwhr->lpszPath) + 15;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT; UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
sprintfW(url, szFormat2, lpwhs->lpszServerName, lpwhs->nServerPort); sprintfW(url, szFormat2, lpwhs->lpszHostName, lpwhs->nServerPort);
if( lpwhr->lpszPath[0] != '/' ) if( lpwhr->lpszPath[0] != '/' )
strcatW( url, szSlash ); strcatW( url, szSlash );
...@@ -949,7 +949,8 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC, ...@@ -949,7 +949,8 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC,
if(lpwhr->lpszPath != szNul) if(lpwhr->lpszPath != szNul)
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath); HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
lpwhr->lpszPath = url; lpwhr->lpszPath = url;
/* FIXME: Do I have to free lpwhs->lpszServerName here ? */
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
lpwhs->lpszServerName = WININET_strdupW(UrlComponents.lpszHostName); lpwhs->lpszServerName = WININET_strdupW(UrlComponents.lpszHostName);
lpwhs->nServerPort = UrlComponents.nPort; lpwhs->nServerPort = UrlComponents.nPort;
...@@ -1058,7 +1059,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -1058,7 +1059,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
HTTP_ProcessHeader(lpwhr, g_szHost, UrlComponents.lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); HTTP_ProcessHeader(lpwhr, g_szHost, UrlComponents.lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
} }
else else
HTTP_ProcessHeader(lpwhr, g_szHost, lpwhs->lpszServerName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); HTTP_ProcessHeader(lpwhr, g_szHost, lpwhs->lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER) if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER)
lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ? lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ?
...@@ -1843,6 +1844,8 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST ...@@ -1843,6 +1844,8 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
HTTP_ADDHDR_FLAG_ADD_IF_NEW); HTTP_ADDHDR_FLAG_ADD_IF_NEW);
#endif #endif
HeapFree(GetProcessHeap(), 0, lpwhs->lpszHostName);
lpwhs->lpszHostName = WININET_strdupW(hostName);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
lpwhs->lpszServerName = WININET_strdupW(hostName); lpwhs->lpszServerName = WININET_strdupW(hostName);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName);
...@@ -2125,7 +2128,10 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, ...@@ -2125,7 +2128,10 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
FIXME("Proxy bypass is ignored.\n"); FIXME("Proxy bypass is ignored.\n");
} }
if (NULL != lpszServerName) if (NULL != lpszServerName)
{
lpwhs->lpszServerName = WININET_strdupW(lpszServerName); lpwhs->lpszServerName = WININET_strdupW(lpszServerName);
lpwhs->lpszHostName = WININET_strdupW(lpszServerName);
}
if (NULL != lpszUserName) if (NULL != lpszUserName)
lpwhs->lpszUserName = WININET_strdupW(lpszUserName); lpwhs->lpszUserName = WININET_strdupW(lpszUserName);
lpwhs->nServerPort = nServerPort; lpwhs->nServerPort = nServerPort;
...@@ -2843,6 +2849,7 @@ static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr) ...@@ -2843,6 +2849,7 @@ static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr)
TRACE("%p\n", lpwhs); TRACE("%p\n", lpwhs);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszHostName);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName);
HeapFree(GetProcessHeap(), 0, lpwhs); HeapFree(GetProcessHeap(), 0, lpwhs);
......
...@@ -164,7 +164,8 @@ typedef struct ...@@ -164,7 +164,8 @@ typedef struct
typedef struct typedef struct
{ {
WININETHANDLEHEADER hdr; WININETHANDLEHEADER hdr;
LPWSTR lpszServerName; LPWSTR lpszHostName; /* the final destination of the request */
LPWSTR lpszServerName; /* the name of the server we directly connect to */
LPWSTR lpszUserName; LPWSTR lpszUserName;
INTERNET_PORT nServerPort; INTERNET_PORT nServerPort;
struct sockaddr_in socketAddress; struct sockaddr_in socketAddress;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment