wininet: Always send a content length header, even if there is no content.

This commit is contained in:
Hans Leidekker 2007-10-28 16:32:46 +01:00 committed by Alexandre Julliard
parent e3b8e2f2dd
commit 64359c2432
2 changed files with 17 additions and 10 deletions

View File

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

View File

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