wine/dlls/wininet http.c
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Nov 28 14:04:35 CST 2005
ChangeSet ID: 21503
CVSROOT: /opt/cvs-commit
Module name: wine
Changes by: julliard at winehq.org 2005/11/28 14:04:34
Modified files:
dlls/wininet : http.c
Log message:
Aric Stewart <aric at codeweavers.com>
Allow HttpEndRequest to process 302 and 301 redirects. Append Host
port if non standard on the redirect host header and make sure to
append the extra information (parameters) and such to the location if
present. Additionally check to see if we are redirecting to https and
if so set the appropriate port.
Patch: http://cvs.winehq.org/patch.py?id=21503
Old revision New revision Changes Path
1.123 1.124 +56 -5 wine/dlls/wininet/http.c
Index: wine/dlls/wininet/http.c
diff -u -p wine/dlls/wininet/http.c:1.123 wine/dlls/wininet/http.c:1.124
--- wine/dlls/wininet/http.c:1.123 28 Nov 2005 20: 4:34 -0000
+++ wine/dlls/wininet/http.c 28 Nov 2005 20: 4:34 -0000
@@ -95,7 +95,12 @@ static BOOL HTTP_DeleteCustomHeader(LPWI
static LPWSTR HTTP_build_req( LPCWSTR *list, int len );
static BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
LPCWSTR username, LPCWSTR password );
-
+static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD
+ dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD
+ lpdwIndex);
+static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl,
+ LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD
+ dwOptionalLength);
/***********************************************************************
* HTTP_Tokenize (internal)
@@ -608,6 +613,26 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hR
/* We appear to do nothing with the buffer.. is that correct? */
+ if(!(lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT))
+ {
+ DWORD dwCode,dwCodeLength=sizeof(DWORD),dwIndex=0;
+ if(HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,&dwCode,&dwCodeLength,&dwIndex) &&
+ (dwCode==302 || dwCode==301))
+ {
+ WCHAR szNewLocation[2048];
+ DWORD dwBufferSize=2048;
+ dwIndex=0;
+ if(HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex))
+ {
+ static const WCHAR szGET[] = { 'G','E','T', 0 };
+ /* redirects are always GETs */
+ HeapFree(GetProcessHeap(),0,lpwhr->lpszVerb);
+ lpwhr->lpszVerb = WININET_strdupW(szGET);
+ return HTTP_HandleRedirect(lpwhr, szNewLocation, NULL, 0, NULL, 0);
+ }
+ }
+ }
+
TRACE("%i <--\n",rc);
return rc;
}
@@ -1783,6 +1808,12 @@ static BOOL HTTP_HandleRedirect(LPWININE
URL_COMPONENTSW urlComponents;
WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
WCHAR password[1024], extra[1024];
+ extra[0] = 0;
+ password[0] = 0;
+ userName[0] = 0;
+ hostName[0] = 0;
+ protocol[0] = 0;
+
urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
urlComponents.lpszScheme = protocol;
urlComponents.dwSchemeLength = 32;
@@ -1800,7 +1831,12 @@ static BOOL HTTP_HandleRedirect(LPWININE
return FALSE;
if (urlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
- urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
+ {
+ if (lstrlenW(protocol)>4) /*https*/
+ urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
+ else /*http*/
+ urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
+ }
#if 0
/*
@@ -1822,13 +1858,26 @@ static BOOL HTTP_HandleRedirect(LPWININE
HeapFree(GetProcessHeap(), 0, lpwhs->lpszHostName);
lpwhs->lpszHostName = WININET_strdupW(hostName);
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
- lpwhs->lpszServerName = WININET_strdupW(hostName);
+ if (urlComponents.nPort != INTERNET_DEFAULT_HTTP_PORT &&
+ urlComponents.nPort != INTERNET_DEFAULT_HTTPS_PORT)
+ {
+ int len;
+ static WCHAR fmt[] = {'%','s',':','%','i',0};
+ len = lstrlenW(hostName);
+ len+=6;
+ lpwhs->lpszServerName = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
+ sprintfW(lpwhs->lpszServerName,fmt,hostName,urlComponents.nPort);
+ }
+ else
+ lpwhs->lpszServerName = WININET_strdupW(hostName);
+
+ HTTP_ProcessHeader(lpwhr, g_szHost, lpwhs->lpszServerName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
+
+
HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName);
lpwhs->lpszUserName = WININET_strdupW(userName);
lpwhs->nServerPort = urlComponents.nPort;
- HTTP_ProcessHeader(lpwhr, g_szHost, hostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
-
SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_RESOLVING_NAME,
lpwhs->lpszServerName,
@@ -1841,6 +1890,8 @@ static BOOL HTTP_HandleRedirect(LPWININE
return FALSE;
}
+ StrCatW(path,extra);
+
SendAsyncCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_NAME_RESOLVED,
&(lpwhs->socketAddress),
More information about the wine-cvs
mailing list