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

This commit is contained in:
Hans Leidekker 2008-05-09 13:12:42 +02:00 committed by Alexandre Julliard
parent eb18ce9d4e
commit aec0e93d23
2 changed files with 29 additions and 1 deletions

View File

@ -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)
{

View File

@ -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);