ChangeSet ID: 21457 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/28 05:01:18
Modified files: dlls/wininet : http.c internet.h
Log message: Robert Shearman rob@codeweavers.com 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.
Patch: http://cvs.winehq.org/patch.py?id=21457
Old revision New revision Changes Path 1.114 1.115 +12 -5 wine/dlls/wininet/http.c 1.42 1.43 +2 -1 wine/dlls/wininet/internet.h
Index: wine/dlls/wininet/http.c diff -u -p wine/dlls/wininet/http.c:1.114 wine/dlls/wininet/http.c:1.115 --- wine/dlls/wininet/http.c:1.114 28 Nov 2005 11: 1:18 -0000 +++ wine/dlls/wininet/http.c 28 Nov 2005 11: 1:18 -0000 @@ -933,15 +933,15 @@ static BOOL HTTP_DealWithProxy( LPWININE if( !lpwhr->lpszPath ) lpwhr->lpszPath = (LPWSTR)szNul; 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 */ - len = strlenW(lpwhs->lpszServerName) + strlenW(lpwhr->lpszPath) + 15; + len = strlenW(lpwhs->lpszHostName) + strlenW(lpwhr->lpszPath) + 15; url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
- sprintfW(url, szFormat2, lpwhs->lpszServerName, lpwhs->nServerPort); + sprintfW(url, szFormat2, lpwhs->lpszHostName, lpwhs->nServerPort);
if( lpwhr->lpszPath[0] != '/' ) strcatW( url, szSlash ); @@ -949,7 +949,8 @@ static BOOL HTTP_DealWithProxy( LPWININE if(lpwhr->lpszPath != szNul) HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath); lpwhr->lpszPath = url; - /* FIXME: Do I have to free lpwhs->lpszServerName here ? */ + + HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); lpwhs->lpszServerName = WININET_strdupW(UrlComponents.lpszHostName); lpwhs->nServerPort = UrlComponents.nPort;
@@ -1058,7 +1059,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(L HTTP_ProcessHeader(lpwhr, g_szHost, UrlComponents.lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); } 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) lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ? @@ -1843,6 +1844,8 @@ static BOOL HTTP_HandleRedirect(LPWININE HTTP_ADDHDR_FLAG_ADD_IF_NEW); #endif
+ HeapFree(GetProcessHeap(), 0, lpwhs->lpszHostName); + lpwhs->lpszHostName = WININET_strdupW(hostName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); lpwhs->lpszServerName = WININET_strdupW(hostName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName); @@ -2125,7 +2128,10 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW FIXME("Proxy bypass is ignored.\n"); } if (NULL != lpszServerName) + { lpwhs->lpszServerName = WININET_strdupW(lpszServerName); + lpwhs->lpszHostName = WININET_strdupW(lpszServerName); + } if (NULL != lpszUserName) lpwhs->lpszUserName = WININET_strdupW(lpszUserName); lpwhs->nServerPort = nServerPort; @@ -2843,6 +2849,7 @@ static void HTTP_CloseHTTPSessionHandle(
TRACE("%p\n", lpwhs);
+ HeapFree(GetProcessHeap(), 0, lpwhs->lpszHostName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName); HeapFree(GetProcessHeap(), 0, lpwhs); Index: wine/dlls/wininet/internet.h diff -u -p wine/dlls/wininet/internet.h:1.42 wine/dlls/wininet/internet.h:1.43 --- wine/dlls/wininet/internet.h:1.42 28 Nov 2005 11: 1:18 -0000 +++ wine/dlls/wininet/internet.h 28 Nov 2005 11: 1:18 -0000 @@ -164,7 +164,8 @@ typedef struct typedef struct { 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; INTERNET_PORT nServerPort; struct sockaddr_in socketAddress;