http: header replacement

Aric Stewart aric at codeweavers.com
Mon Nov 21 11:27:39 CST 2005


fix some logic to allow HTTP_ADDREQ_FLAG_ADD to replace existing 
headers. Also adding a test for some header adding flags.

more fixes for gmail and picasa.
-------------- next part --------------
Index: dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.111
diff -u -r1.111 http.c
--- dlls/wininet/http.c	21 Nov 2005 15:17:55 -0000	1.111
+++ dlls/wininet/http.c	21 Nov 2005 17:23:59 -0000
@@ -2692,7 +2692,8 @@
     else
         lphttpHdr->wFlags &= ~HDR_ISREQUEST;
 
-    if (!lphttpHdr->lpszValue && (dwModifier & (HTTP_ADDHDR_FLAG_ADD|HTTP_ADDHDR_FLAG_ADD_IF_NEW)))
+    if (!lphttpHdr->lpszValue && (dwModifier & HTTP_ADDHDR_FLAG_ADD || 
+                dwModifier & HTTP_ADDHDR_FLAG_ADD_IF_NEW))
     {
         INT slen;
 
@@ -2718,7 +2719,8 @@
     }
     else if (lphttpHdr->lpszValue)
     {
-        if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE)
+        if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE || 
+                dwModifier & HTTP_ADDHDR_FLAG_ADD)
             bSuccess = HTTP_ReplaceHeaderValue( lphttpHdr, value );
         else if (dwModifier & COALESCEFLASG)
         {
Index: dlls/wininet/tests/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/tests/http.c,v
retrieving revision 1.32
diff -u -r1.32 http.c
--- dlls/wininet/tests/http.c	21 Nov 2005 15:17:55 -0000	1.32
+++ dlls/wininet/tests/http.c	21 Nov 2005 17:24:10 -0000
@@ -1098,7 +1098,36 @@
     ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
     ok(InternetCloseHandle(hSession), "Close session handle failed\n");
 }
-    
+
+static void HttpHeaders_test(void)
+{
+    HINTERNET hSession;
+    HINTERNET hConnect;
+    HINTERNET hRequest;
+
+    hSession = InternetOpen("Wine Regression Test",
+            INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
+    ok( hSession != NULL ,"Unable to open Internet session\n");
+    hConnect = InternetConnect(hSession, "crossover.codeweavers.com",
+            INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
+            0);
+    ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
+    hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php",
+            NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
+    ok( hRequest != NULL, "Failed to open request handle\n");
+
+    ok(HttpAddRequestHeaders(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD), "Failed to add new header\n");
+    ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD), "Failed to replace header using HTTP_ADDREQ_FLAG_ADD\n");
+    ok(HttpAddRequestHeaders(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
+    ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
+
+    ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
+    ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
+    ok(InternetCloseHandle(hSession), "Close session handle failed\n");
+}
+
+
+
 START_TEST(http)
 {
     InternetReadFile_test(INTERNET_FLAG_ASYNC);
@@ -1113,4 +1142,5 @@
     InternetTimeToSystemTimeW_test();
     InternetCreateUrlA_test();
     HttpSendRequestEx_test();
+    HttpHeaders_test();
 }


More information about the wine-patches mailing list