Mike McCormack : WININET: Clean up HttpQueryInfo.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 30 05:44:01 CST 2006


Module: wine
Branch: refs/heads/master
Commit: ae300883faa29ddad5c65aeac5cad682380e4cd3
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=ae300883faa29ddad5c65aeac5cad682380e4cd3

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu Mar 30 18:01:48 2006 +0900

WININET: Clean up HttpQueryInfo.

Fixes another return FALSE without SetLastError.

---

 dlls/wininet/http.c |   76 ++++++++++++++++++---------------------------------
 1 files changed, 27 insertions(+), 49 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 48026a0..70dfc38 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1291,28 +1291,18 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( 
     LPHTTPHEADERW lphttpHdr = NULL;
     BOOL bSuccess = FALSE;
     BOOL request_only = dwInfoLevel & HTTP_QUERY_FLAG_REQUEST_HEADERS;
-
+    INT requested_index = lpdwIndex ? *lpdwIndex : 0;
+    INT level = (dwInfoLevel & ~HTTP_QUERY_MODIFIER_FLAGS_MASK);
+    INT index = -1;
 
     /* Find requested header structure */
-    if ((dwInfoLevel & ~HTTP_QUERY_MODIFIER_FLAGS_MASK) == HTTP_QUERY_CUSTOM)
+    switch (level)
     {
-        INT requested_index = (lpdwIndex)?(*lpdwIndex):0;
-        INT index = HTTP_GetCustomHeaderIndex(lpwhr, (LPWSTR)lpBuffer, 
-                requested_index,request_only);
+    case HTTP_QUERY_CUSTOM:
+        index = HTTP_GetCustomHeaderIndex(lpwhr, lpBuffer, requested_index, request_only);
+        break;
 
-        if (index < 0)
-            return bSuccess;
-        else
-            lphttpHdr = &lpwhr->pCustHeaders[index];
-
-        if (lpdwIndex)
-            (*lpdwIndex)++;
-    }
-    else
-    {
-        INT index = dwInfoLevel & ~HTTP_QUERY_MODIFIER_FLAGS_MASK;
-
-        if (index == HTTP_QUERY_RAW_HEADERS_CRLF)
+    case HTTP_QUERY_RAW_HEADERS_CRLF:
         {
             DWORD len = strlenW(lpwhr->lpszRawHeaders);
             if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
@@ -1328,7 +1318,7 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( 
 
             return TRUE;
         }
-        else if (index == HTTP_QUERY_RAW_HEADERS)
+    case HTTP_QUERY_RAW_HEADERS:
         {
             static const WCHAR szCrLf[] = {'\r','\n',0};
             LPWSTR * ppszRawHeaderLines = HTTP_Tokenize(lpwhr->lpszRawHeaders, szCrLf);
@@ -1361,7 +1351,7 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( 
 
             return TRUE;
         }
-        else if (index == HTTP_QUERY_STATUS_TEXT)
+    case HTTP_QUERY_STATUS_TEXT:
         {
             DWORD len = strlenW(lpwhr->lpszStatusText);
             if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
@@ -1377,7 +1367,7 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( 
 
             return TRUE;
         }
-        else if (index == HTTP_QUERY_VERSION)
+    case HTTP_QUERY_VERSION:
         {
             DWORD len = strlenW(lpwhr->lpszVersion);
             if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
@@ -1393,50 +1383,38 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( 
 
             return TRUE;
         }
-	    else if (index >= 0 && index <= HTTP_QUERY_MAX )
-	    {
+    default:
+        if (level >= 0 && level <= HTTP_QUERY_MAX )
+        {
             int i;
-            for (i = 0; i <  sizeof(SORTED_STANDARD_HEADERS)/sizeof(std_hdr_data) ; i++)
+            for (i = 0; i < sizeof(SORTED_STANDARD_HEADERS)/sizeof(std_hdr_data) ; i++)
             {
-                if (SORTED_STANDARD_HEADERS[i].hdrIndex == index)
+                if (SORTED_STANDARD_HEADERS[i].hdrIndex == level)
                 {
-                    INT requested_index = (lpdwIndex)?(*lpdwIndex):0;
-                    INT index = HTTP_GetCustomHeaderIndex(lpwhr,
+                    index = HTTP_GetCustomHeaderIndex(lpwhr,
                             (LPWSTR)SORTED_STANDARD_HEADERS[i].hdrStr,
                             requested_index,request_only);
-
-                    if (index < 0)
-                        break;
-                    lphttpHdr = &lpwhr->pCustHeaders[index];
-
-                    if (lpdwIndex)
-                        (*lpdwIndex)++;
-
                     break;
                 }
             }
-
-            if (!lphttpHdr)
-            {
-                SetLastError(ERROR_HTTP_HEADER_NOT_FOUND);
-                return bSuccess;
-            }
-	    }
-	    else
-        {
-            SetLastError(ERROR_HTTP_HEADER_NOT_FOUND);
-            return bSuccess;
         }
     }
 
+    if (index >= 0)
+        lphttpHdr = &lpwhr->pCustHeaders[index];
+
     /* Ensure header satisifies requested attributes */
-    if ((dwInfoLevel & HTTP_QUERY_FLAG_REQUEST_HEADERS) &&
-	    (~lphttpHdr->wFlags & HDR_ISREQUEST))
+    if (!lphttpHdr ||
+        ((dwInfoLevel & HTTP_QUERY_FLAG_REQUEST_HEADERS) &&
+         (~lphttpHdr->wFlags & HDR_ISREQUEST)))
     {
         SetLastError(ERROR_HTTP_HEADER_NOT_FOUND);
-	return bSuccess;
+        return bSuccess;
     }
 
+    if (lpdwIndex)
+        (*lpdwIndex)++;
+
     /* coalesce value to reuqested type */
     if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER)
     {




More information about the wine-cvs mailing list