From: Paul Gofman pgofman@codeweavers.com
--- dlls/winhttp/request.c | 2 +- dlls/winhttp/tests/winhttp.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 64f70b61a96..e046b05581c 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -2185,7 +2185,7 @@ static DWORD send_request( struct request *request, const WCHAR *headers, DWORD if (request->creds[TARGET_SERVER][SCHEME_BASIC].username) do_authorization( request, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC );
- if (total_len || (request->verb && !wcscmp( request->verb, L"POST" ))) + if (total_len || (request->verb && (!wcscmp( request->verb, L"POST" ) || !wcscmp( request->verb, L"PUT" )))) { WCHAR length[21]; /* decimal long int + null */ swprintf( length, ARRAY_SIZE(length), L"%ld", total_len ); diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 45eaf1a673a..b7deaea324a 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -2541,6 +2541,11 @@ static DWORD CALLBACK server_thread(LPVOID param) ok(!!strstr(buffer, "Cookie: 111\r\n"), "Header missing from request %s.\n", debugstr_a(buffer)); send(c, okmsg, sizeof(okmsg) - 1, 0); } + if (strstr(buffer, "PUT /test")) + { + ok(!!strstr(buffer, "Content-Length: 0\r\n"), "Header missing from request %s.\n", debugstr_a(buffer)); + send(c, okmsg, sizeof(okmsg) - 1, 0); + } shutdown(c, 2); closesocket(c); c = -1; @@ -2633,8 +2638,15 @@ static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path) memset(buffer, 0, sizeof(buffer)); ret = WinHttpReadData(req, buffer, sizeof buffer, &count); ok(ret, "failed to read data %lu\n", GetLastError()); - ok(count == sizeof page1 - 1, "count was wrong\n"); - ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n"); + if (verb && !wcscmp(verb, L"PUT")) + { + ok(!count, "got count %ld\n", count); + } + else + { + ok(count == sizeof page1 - 1, "got count %ld\n", count); + ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n"); + }
WinHttpCloseHandle(req); WinHttpCloseHandle(con); @@ -5795,7 +5807,6 @@ START_TEST (winhttp) test_WinHttpGetProxyForUrl(); test_chunked_read(); test_max_http_automatic_redirects(); - si.event = CreateEventW(NULL, 0, 0, NULL); si.port = 7532;
@@ -5809,10 +5820,10 @@ START_TEST (winhttp) CloseHandle(thread); return; } - test_IWinHttpRequest(si.port); test_connection_info(si.port); test_basic_request(si.port, NULL, L"/basic"); + test_basic_request(si.port, L"PUT", L"/test"); test_no_headers(si.port); test_no_content(si.port); test_head_request(si.port);