Jacek Caban : wininet: Added special case for HTTP_QUERY_STATUS_CODE in HttpQueryInfo.

Alexandre Julliard julliard at winehq.org
Thu May 3 14:23:49 CDT 2012


Module: wine
Branch: master
Commit: 0d76489353eed2a35fecc5c6491f3fc08c3e9c80
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0d76489353eed2a35fecc5c6491f3fc08c3e9c80

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu May  3 12:20:25 2012 +0200

wininet: Added special case for HTTP_QUERY_STATUS_CODE in HttpQueryInfo.

---

 dlls/wininet/http.c       |   30 +++++++++++++++++++++++++++++-
 dlls/wininet/tests/http.c |    4 +++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index d5697ae..84b83f2 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3421,6 +3421,34 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
         index = HTTP_GetCustomHeaderIndex(request, header_lookup[request->read_gzip ? HTTP_QUERY_CONTENT_TYPE : level],
                 requested_index,request_only);
         break;
+    case HTTP_QUERY_STATUS_CODE: {
+        DWORD res = ERROR_SUCCESS;
+
+        if(request_only || requested_index)
+            break;
+
+        if(dwInfoLevel & HTTP_QUERY_FLAG_NUMBER) {
+            if(*lpdwBufferLength >= sizeof(DWORD))
+                *(DWORD*)lpBuffer = request->status_code;
+            else
+                res = ERROR_INSUFFICIENT_BUFFER;
+            *lpdwBufferLength = sizeof(DWORD);
+        }else {
+            WCHAR buf[12];
+            DWORD size;
+            static const WCHAR formatW[] = {'%','u',0};
+
+            size = (sprintfW(buf, formatW, request->status_code)+1) * sizeof(WCHAR);
+
+            if(size <= *lpdwBufferLength)
+                memcpy(lpBuffer, buf, size);
+            else
+                res = ERROR_INSUFFICIENT_BUFFER;
+
+            *lpdwBufferLength = size;
+        }
+        return res;
+    }
     default:
         assert (LAST_TABLE_HEADER == (HTTP_QUERY_UNLESS_MODIFIED_SINCE + 1));
 
@@ -3440,7 +3468,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
         return ERROR_HTTP_HEADER_NOT_FOUND;
     }
 
-    if (lpdwIndex && level != HTTP_QUERY_STATUS_CODE) (*lpdwIndex)++;
+    if (lpdwIndex) (*lpdwIndex)++;
 
     /* coalesce value to requested type */
     if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER && lpBuffer)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 6050220..7e21a22 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -473,6 +473,8 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
             goto abort;
     }
 
+    test_status_code(hor, 0);
+
     trace("HttpSendRequestA -->\n");
     if(test->post_data) {
         post_len = strlen(test->post_data);
@@ -2455,7 +2457,7 @@ static void test_response_without_headers(int port)
     size = sizeof(status);
     SetLastError(0xdeadbeef);
     r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
-    todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError());
+    ok(r, "HttpQueryInfo failed %u\n", GetLastError());
     todo_wine ok(status == 200, "expected status 200 got %u\n", status);
 
     buffer[0] = 0;




More information about the wine-cvs mailing list