Hans Leidekker : wininet: Don' t overwrite content length header in HttpSendRequest.

Alexandre Julliard julliard at winehq.org
Mon May 12 07:12:30 CDT 2008


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

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Fri May  9 13:12:42 2008 +0200

wininet: Don't overwrite content length header in HttpSendRequest.

---

 dlls/wininet/http.c       |    2 +-
 dlls/wininet/tests/http.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 3cafcae..b8e3b4d 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3171,7 +3171,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
     if (dwContentLength || !strcmpW(lpwhr->lpszVerb, szPost))
     {
         sprintfW(contentLengthStr, szContentLength, dwContentLength);
-        HTTP_HttpAddRequestHeadersW(lpwhr, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE);
+        HTTP_HttpAddRequestHeadersW(lpwhr, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
     }
     if (lpwhr->lpHttpSession->lpAppInfo->lpszAgent)
     {
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 705fcac..58907ba 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1452,6 +1452,17 @@ static DWORD CALLBACK server_thread(LPVOID param)
             send(c, page1, sizeof page1-1, 0);
         }
 
+        if (strstr(buffer, "POST /test7"))
+        {
+            if (strstr(buffer, "Content-Length: 100"))
+            {
+                send(c, okmsg, sizeof okmsg-1, 0);
+                send(c, page1, sizeof page1-1, 0);
+            }
+            else
+                send(c, notokmsg, sizeof notokmsg-1, 0);
+        }
+
         if (strstr(buffer, "GET /quit"))
         {
             send(c, okmsg, sizeof okmsg-1, 0);
@@ -1654,6 +1665,23 @@ static void test_header_handling_order(int port)
     ok(status == 200, "request failed with status %u\n", status);
 
     InternetCloseHandle(request);
+
+    request = HttpOpenRequest(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+    ok(request != NULL, "HttpOpenRequest failed\n");
+
+    ret = HttpAddRequestHeaders(request, "Content-Length: 100\r\n", ~0UL, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+    ok(ret, "HttpAddRequestHeaders failed\n");
+
+    ret = HttpSendRequest(request, connection, ~0UL, NULL, 0);
+    ok(ret, "HttpSendRequest failed\n");
+
+    status = 0;
+    size = sizeof(status);
+    ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+    ok(ret, "HttpQueryInfo failed\n");
+    ok(status == 200, "request failed with status %u\n", status);
+
+    InternetCloseHandle(request);
     InternetCloseHandle(connect);
     InternetCloseHandle(session);
 }




More information about the wine-cvs mailing list