Commit aec0e93d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wininet: Don't overwrite content length header in HttpSendRequest.

parent eb18ce9d
......@@ -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)
{
......
......@@ -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);
......@@ -1654,6 +1665,23 @@ static void test_header_handling_order(int port)
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);
}
......
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