wininet: Added special case for HTTP_QUERY_STATUS_CODE in HttpQueryInfo.
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 @@
         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 @@
         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 @@
             goto abort;
     }
 
+    test_status_code(hor, 0);
+
     trace("HttpSendRequestA -->\n");
     if(test->post_data) {
         post_len = strlen(test->post_data);
@@ -2455,7 +2457,7 @@
     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;