diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index f496733c419..53d6fbac9e6 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2589,6 +2589,9 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, BOOL loop_next; INTERNET_ASYNC_RESULT iar; static const WCHAR szClose[] = { 'C','l','o','s','e',0 }; + static const WCHAR szContentLength[] = + { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 }; + WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \r\n */ + 20 /* int */ ]; TRACE("--> %p\n", lpwhr); @@ -2599,16 +2602,8 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, HTTP_FixVerb(lpwhr); - /* if we are using optional stuff, we must add the fixed header of that option length */ - if (dwContentLength > 0) - { - static const WCHAR szContentLength[] = { - 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0}; - WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \n\r */ + 20 /* int */ ]; - sprintfW(contentLengthStr, szContentLength, dwContentLength); - HTTP_HttpAddRequestHeadersW(lpwhr, contentLengthStr, -1L, - HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE); - } + sprintfW(contentLengthStr, szContentLength, dwContentLength); + HTTP_HttpAddRequestHeadersW(lpwhr, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE); do { diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 589fe8a4d58..a8f989b0acb 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1302,6 +1302,17 @@ static DWORD CALLBACK server_thread(LPVOID param) send(c, notokmsg, sizeof notokmsg-1, 0); } + if (strstr(buffer, "/test5")) + { + if (strstr(buffer, "Content-Length: 0")) + { + 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, "/quit")) { send(c, okmsg, sizeof okmsg-1, 0); @@ -1526,6 +1537,7 @@ static void test_http_connection(void) test_proxy_indirect(si.port); test_proxy_direct(si.port); test_header_handling_order(si.port); + test_basic_request(si.port, "/test5"); /* send the basic request again to shutdown the server thread */ test_basic_request(si.port, "/quit");