diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 3cafcae3862bd8b5d262d5f8aaa1ce6a64f3d9a5..b8e3b4dd8e525144daf70099ac3bcc7c0726241a 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 705fcac60202ca7da0d178927ca88b72ed3e01d3..58907baf82be5b2a00b4f38e9f2d787827241275 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); @@ -1653,6 +1664,23 @@ static void test_header_handling_order(int port) ok(ret, "HttpQueryInfo failed\n"); 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);