wininet: Only set the content length header if it's not explicitly set by the user.

Hans Leidekker hans at codeweavers.com
Mon May 26 07:09:10 CDT 2014


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

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 97becd4..c7e3474 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4851,7 +4851,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
     if (dwContentLength || strcmpW(request->verb, szGET))
     {
         sprintfW(contentLengthStr, szContentLength, dwContentLength);
-        HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_REPLACE);
+        HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
         request->bytesToWrite = dwContentLength;
     }
     if (request->session->appInfo->agent)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 70e82db..41f4c5b 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2654,10 +2654,10 @@ static void test_header_handling_order(int port)
 {
     static const char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
     static const char connection[]    = "Connection: Close";
-
     static const char *types[2] = { "*", NULL };
+    char data[32];
     HINTERNET session, connect, request;
-    DWORD size, status;
+    DWORD size, status, data_len;
     BOOL ret;
 
     session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
@@ -2693,6 +2693,10 @@ static void test_header_handling_order(int port)
     ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status);
 
     InternetCloseHandle(request);
+    InternetCloseHandle(connect);
+
+    connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(connect != NULL, "InternetConnect failed\n");
 
     request = HttpOpenRequestA(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
     ok(request != NULL, "HttpOpenRequest failed\n");
@@ -2707,7 +2711,30 @@ static void test_header_handling_order(int port)
     size = sizeof(status);
     ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
     ok(ret, "HttpQueryInfo failed\n");
-    ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status);
+    ok(status == 200, "got status %u, expected 200\n", status);
+
+    InternetCloseHandle(request);
+    InternetCloseHandle(connect);
+
+    connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(connect != NULL, "InternetConnect failed\n");
+
+    request = HttpOpenRequestA(connect, "POST", "/test7b", NULL, NULL, types, 0, 0);
+    ok(request != NULL, "HttpOpenRequest failed\n");
+
+    ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+    ok(ret, "HttpAddRequestHeaders failed\n");
+
+    data_len = sizeof(data);
+    memset(data, 'a', sizeof(data));
+    ret = HttpSendRequestA(request, connection, ~0u, data, data_len);
+    ok(ret, "HttpSendRequest failed\n");
+
+    status = 0;
+    size = sizeof(status);
+    ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+    ok(ret, "HttpQueryInfo failed\n");
+    ok(status == 200, "got status %u, expected 200\n", status);
 
     InternetCloseHandle(request);
     InternetCloseHandle(connect);
-- 
2.0.0.rc4





More information about the wine-patches mailing list