Rob Shearman : wininet:
Make HTTP_HandleRedirect no longer call HTTP_HttpSendRequestW.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Dec 7 07:07:57 CST 2006
Module: wine
Branch: master
Commit: 4319ec6b838edb6bc5b289d37187b90c9f3e21ed
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4319ec6b838edb6bc5b289d37187b90c9f3e21ed
Author: Rob Shearman <rob at codeweavers.com>
Date: Thu Dec 7 00:53:27 2006 +0000
wininet: Make HTTP_HandleRedirect no longer call HTTP_HttpSendRequestW.
Make the redirect handling in HTTP_HttpSendRequestW iterate instead of recurse.
---
dlls/wininet/http.c | 70 ++++++++++++++++++++++++--------------------------
1 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 36c85da..f6e3421 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -102,9 +102,7 @@ static BOOL HTTP_InsertProxyAuthorizatio
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, DWORD dwContentLength);
+static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl);
LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW req, LPCWSTR head)
@@ -636,7 +634,9 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hR
/* redirects are always GETs */
HeapFree(GetProcessHeap(),0,lpwhr->lpszVerb);
lpwhr->lpszVerb = WININET_strdupW(szGET);
- return HTTP_HandleRedirect(lpwhr, szNewLocation, NULL, 0, NULL, 0, 0);
+ rc = HTTP_HandleRedirect(lpwhr, szNewLocation);
+ if (rc)
+ rc = HTTP_HttpSendRequestW(lpwhr, NULL, 0, NULL, 0, 0, TRUE);
}
}
}
@@ -1928,9 +1928,7 @@ BOOL WINAPI HttpSendRequestA(HINTERNET h
/***********************************************************************
* HTTP_HandleRedirect (internal)
*/
-static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWSTR lpszHeaders,
- DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
- DWORD dwContentLength)
+static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl)
{
LPWININETHTTPSESSIONW lpwhs = lpwhr->lpHttpSession;
LPWININETAPPINFOW hIC = lpwhs->lpAppInfo;
@@ -2136,8 +2134,7 @@ static BOOL HTTP_HandleRedirect(LPWININE
}
}
- return HTTP_HttpSendRequestW(lpwhr, lpszHeaders, dwHeaderLength, lpOptional,
- dwOptionalLength, dwContentLength, TRUE);
+ return TRUE;
}
/***********************************************************************
@@ -2225,7 +2222,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWINI
INT responseLen;
BOOL loop_next = FALSE;
INTERNET_ASYNC_RESULT iar;
- LPHTTPHEADERW Host;
TRACE("--> %p\n", lpwhr);
@@ -2247,14 +2243,16 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWINI
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE);
}
- Host = HTTP_GetHeader(lpwhr,szHost);
do
{
DWORD len;
char *ascii_req;
- TRACE("Going to url %s %s\n", debugstr_w(Host->lpszValue), debugstr_w(lpwhr->lpszPath));
- loop_next = FALSE;
+ if (TRACE_ON(wininet))
+ {
+ LPHTTPHEADERW Host = HTTP_GetHeader(lpwhr,szHost);
+ TRACE("Going to url %s %s\n", debugstr_w(Host->lpszValue), debugstr_w(lpwhr->lpszPath));
+ }
HTTP_FixURL(lpwhr);
@@ -2315,8 +2313,30 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWINI
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen,
sizeof(DWORD));
-
+
HTTP_ProcessHeaders(lpwhr);
+
+ if (!(lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT) && bSuccess)
+ {
+ DWORD dwCode,dwCodeLength=sizeof(DWORD),dwIndex=0;
+ WCHAR szNewLocation[2048];
+ DWORD dwBufferSize=2048;
+ if (HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,&dwCode,&dwCodeLength,&dwIndex) &&
+ (dwCode==HTTP_STATUS_REDIRECT || dwCode==HTTP_STATUS_MOVED) &&
+ HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex))
+ {
+ INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
+ INTERNET_STATUS_REDIRECT, szNewLocation,
+ dwBufferSize);
+ bSuccess = HTTP_HandleRedirect(lpwhr, szNewLocation);
+ if (bSuccess)
+ {
+ HeapFree(GetProcessHeap(), 0, requestString);
+ loop_next = TRUE;
+ }
+ }
+ }
+
}
else
bSuccess = TRUE;
@@ -2328,28 +2348,6 @@ lend:
HeapFree(GetProcessHeap(), 0, requestString);
/* TODO: send notification for P3P header */
-
- if(!(lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT) && bSuccess && bEndRequest)
- {
- 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))
- {
- INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
- INTERNET_STATUS_REDIRECT, szNewLocation,
- dwBufferSize);
- return HTTP_HandleRedirect(lpwhr, szNewLocation, lpszHeaders,
- dwHeaderLength, lpOptional, dwOptionalLength,
- dwContentLength);
- }
- }
- }
-
iar.dwResult = (DWORD)bSuccess;
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError();
More information about the wine-cvs
mailing list