Jacek Caban : wininet: Directly return error status from HTTP_HandleRedirect.
Alexandre Julliard
julliard at winehq.org
Thu Dec 3 10:29:55 CST 2009
Module: wine
Branch: master
Commit: a9ecdc6024c2e5011b7973a68c0b506896aca39c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a9ecdc6024c2e5011b7973a68c0b506896aca39c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Dec 3 14:49:56 2009 +0100
wininet: Directly return error status from HTTP_HandleRedirect.
---
dlls/wininet/http.c | 35 +++++++++++++----------------------
1 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 0aa78b5..19a34cb 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -208,7 +208,6 @@ static BOOL HTTP_DeleteCustomHeader(http_request_t *req, DWORD index);
static LPWSTR HTTP_build_req( LPCWSTR *list, int len );
static BOOL HTTP_HttpQueryInfoW(http_request_t*, DWORD, LPVOID, LPDWORD, LPDWORD);
static LPWSTR HTTP_GetRedirectURL(http_request_t *req, LPCWSTR lpszUrl);
-static BOOL HTTP_HandleRedirect(http_request_t *req, LPCWSTR lpszUrl);
static UINT HTTP_DecodeBase64(LPCWSTR base64, LPSTR bin);
static BOOL HTTP_VerifyValidHeader(http_request_t *req, LPCWSTR field);
static void HTTP_DrainContent(http_request_t *req);
@@ -3132,7 +3131,7 @@ static LPWSTR HTTP_GetRedirectURL(http_request_t *lpwhr, LPCWSTR lpszUrl)
/***********************************************************************
* HTTP_HandleRedirect (internal)
*/
-static BOOL HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
+static DWORD HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
{
http_session_t *lpwhs = lpwhr->lpHttpSession;
appinfo_t *hIC = lpwhs->lpAppInfo;
@@ -3170,7 +3169,7 @@ static BOOL HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
urlComponents.lpszExtraInfo = NULL;
urlComponents.dwExtraInfoLength = 0;
if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
- return FALSE;
+ return INTERNET_GetLastError();
if (!strncmpW(szHttp, urlComponents.lpszScheme, strlenW(szHttp)) &&
(lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE))
@@ -3244,15 +3243,13 @@ static BOOL HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
lpwhs->nServerPort = urlComponents.nPort;
NETCON_close(&lpwhr->netConnection);
- if ((res = HTTP_ResolveName(lpwhr)) != ERROR_SUCCESS) {
- INTERNET_SetLastError(res);
- return FALSE;
- }
+ if ((res = HTTP_ResolveName(lpwhr)) != ERROR_SUCCESS)
+ return res;
+
res = NETCON_init(&lpwhr->netConnection, lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE);
- if (res != ERROR_SUCCESS) {
- INTERNET_SetLastError(res);
- return FALSE;
- }
+ if (res != ERROR_SUCCESS)
+ return res;
+
lpwhr->read_pos = lpwhr->read_size = 0;
lpwhr->read_chunked = FALSE;
}
@@ -3289,7 +3286,7 @@ static BOOL HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
if (0 <= index)
HTTP_DeleteCustomHeader(lpwhr, index);
- return TRUE;
+ return ERROR_SUCCESS;
}
/***********************************************************************
@@ -3571,16 +3568,13 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *lpwhr, LPCWSTR lpszHeaders,
HTTP_DrainContent(lpwhr);
if ((new_url = HTTP_GetRedirectURL( lpwhr, szNewLocation )))
{
- BOOL bSuccess;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_REDIRECT,
new_url, (strlenW(new_url) + 1) * sizeof(WCHAR));
- bSuccess = HTTP_HandleRedirect(lpwhr, new_url);
- if (bSuccess)
+ res = HTTP_HandleRedirect(lpwhr, new_url);
+ if (res == ERROR_SUCCESS)
{
HeapFree(GetProcessHeap(), 0, requestString);
loop_next = TRUE;
- }else {
- res = INTERNET_GetLastError();
}
HeapFree( GetProcessHeap(), 0, new_url );
}
@@ -3741,14 +3735,11 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *lpwhr, DWORD dwFlags, DWORD_PT
HTTP_DrainContent(lpwhr);
if ((new_url = HTTP_GetRedirectURL( lpwhr, szNewLocation )))
{
- BOOL rc;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_REDIRECT,
new_url, (strlenW(new_url) + 1) * sizeof(WCHAR));
- rc = HTTP_HandleRedirect(lpwhr, new_url);
- if (rc)
+ res = HTTP_HandleRedirect(lpwhr, new_url);
+ if (res == ERROR_SUCCESS)
res = HTTP_HttpSendRequestW(lpwhr, NULL, 0, NULL, 0, 0, TRUE);
- else
- res = INTERNET_GetLastError();
HeapFree( GetProcessHeap(), 0, new_url );
}
}
More information about the wine-cvs
mailing list