Commit a8c1d5c1 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Always send Content-length with PUT.

parent cc0f4430
......@@ -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 );
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment