Mikołaj Zalewski : wininet: Support HTTP_QUERY_RAW_HEADER_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Aug 16 05:38:38 CDT 2007


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

Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date:   Wed Aug 15 16:29:58 2007 -0700

wininet: Support HTTP_QUERY_RAW_HEADER_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS.

---

 dlls/wininet/http.c       |   28 +++++++++++++++++++++-------
 dlls/wininet/tests/http.c |   14 ++++++++++++++
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 33cfbb5..50fbf5a 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1664,19 +1664,33 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
 
     case HTTP_QUERY_RAW_HEADERS_CRLF:
         {
-            DWORD len = strlenW(lpwhr->lpszRawHeaders);
+            LPWSTR headers;
+            DWORD len;
+            BOOL ret;
+
+            if (request_only)
+                headers = HTTP_BuildHeaderRequestString(lpwhr, lpwhr->lpszVerb, lpwhr->lpszPath, FALSE);
+            else
+                headers = lpwhr->lpszRawHeaders;
+
+	    len = strlenW(headers);
             if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
             {
                 *lpdwBufferLength = (len + 1) * sizeof(WCHAR);
                 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
-                return FALSE;
-            }
-            memcpy(lpBuffer, lpwhr->lpszRawHeaders, (len+1)*sizeof(WCHAR));
-            *lpdwBufferLength = len * sizeof(WCHAR);
+                ret = FALSE;
+            } else
+            {
+                memcpy(lpBuffer, headers, (len+1)*sizeof(WCHAR));
+                *lpdwBufferLength = len * sizeof(WCHAR);
 
-            TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
+                TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
+                ret = TRUE;
+            }
 
-            return TRUE;
+            if (request_only)
+                HeapFree(GetProcessHeap(), 0, headers);
+            return ret;
         }
     case HTTP_QUERY_RAW_HEADERS:
         {
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index b8d391c..00f417d 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -983,11 +983,25 @@ static void HttpHeaders_test(void)
                 buffer,&len,&index),"Unable to query header\n");
     ok(index == 1, "Index was not incremented\n");
     ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
+    ok(len == 5, "Invalid length (exp. 5, got %d)\n", len);
+    ok(buffer[len] == 0, "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
     len = sizeof(buffer);
     strcpy(buffer,"Warning");
     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
                 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
 
+    /* a working query */
+    index = 0;
+    len = sizeof(buffer);
+    ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+                buffer,&len,&index),"Unable to query header\n");
+    /* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
+    ok(strncmp(buffer, "POST /posttest.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
+    ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
+    ok(index == 0, "Index was incremented\n");
+
+
+
     ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
             "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
 




More information about the wine-cvs mailing list