wininet: Add zero value content length header to POST requests only.
This commit is contained in:
parent
c132dd9360
commit
b0912d1151
@ -2565,6 +2565,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
|
|||||||
BOOL loop_next;
|
BOOL loop_next;
|
||||||
INTERNET_ASYNC_RESULT iar;
|
INTERNET_ASYNC_RESULT iar;
|
||||||
static const WCHAR szClose[] = { 'C','l','o','s','e',0 };
|
static const WCHAR szClose[] = { 'C','l','o','s','e',0 };
|
||||||
|
static const WCHAR szPost[] = { 'P','O','S','T',0 };
|
||||||
static const WCHAR szContentLength[] =
|
static const WCHAR szContentLength[] =
|
||||||
{ 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 };
|
{ '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 */ ];
|
WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \r\n */ + 20 /* int */ ];
|
||||||
@ -2577,9 +2578,11 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
|
|||||||
INTERNET_SetLastError(0);
|
INTERNET_SetLastError(0);
|
||||||
|
|
||||||
HTTP_FixVerb(lpwhr);
|
HTTP_FixVerb(lpwhr);
|
||||||
|
if (dwContentLength || !strcmpW(lpwhr->lpszVerb, szPost))
|
||||||
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
|
do
|
||||||
{
|
{
|
||||||
|
@ -1285,8 +1285,13 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||||||
|
|
||||||
if (strstr(buffer, "GET /test1"))
|
if (strstr(buffer, "GET /test1"))
|
||||||
{
|
{
|
||||||
send(c, okmsg, sizeof okmsg-1, 0);
|
if (!strstr(buffer, "Content-Length: 0"))
|
||||||
send(c, page1, sizeof page1-1, 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, "/test2"))
|
if (strstr(buffer, "/test2"))
|
||||||
@ -1316,7 +1321,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||||||
send(c, notokmsg, sizeof notokmsg-1, 0);
|
send(c, notokmsg, sizeof notokmsg-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(buffer, "/test5"))
|
if (strstr(buffer, "POST /test5"))
|
||||||
{
|
{
|
||||||
if (strstr(buffer, "Content-Length: 0"))
|
if (strstr(buffer, "Content-Length: 0"))
|
||||||
{
|
{
|
||||||
@ -1327,7 +1332,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||||||
send(c, notokmsg, sizeof notokmsg-1, 0);
|
send(c, notokmsg, sizeof notokmsg-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(buffer, "/quit"))
|
if (strstr(buffer, "GET /quit"))
|
||||||
{
|
{
|
||||||
send(c, okmsg, sizeof okmsg-1, 0);
|
send(c, okmsg, sizeof okmsg-1, 0);
|
||||||
send(c, page1, sizeof page1-1, 0);
|
send(c, page1, sizeof page1-1, 0);
|
||||||
@ -1343,7 +1348,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_basic_request(int port, const char *url)
|
static void test_basic_request(int port, const char *verb, const char *url)
|
||||||
{
|
{
|
||||||
HINTERNET hi, hc, hr;
|
HINTERNET hi, hc, hr;
|
||||||
DWORD r, count;
|
DWORD r, count;
|
||||||
@ -1355,7 +1360,7 @@ static void test_basic_request(int port, const char *url)
|
|||||||
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
||||||
ok(hc != NULL, "connect failed\n");
|
ok(hc != NULL, "connect failed\n");
|
||||||
|
|
||||||
hr = HttpOpenRequest(hc, NULL, url, NULL, NULL, NULL, 0, 0);
|
hr = HttpOpenRequest(hc, verb, url, NULL, NULL, NULL, 0, 0);
|
||||||
ok(hr != NULL, "HttpOpenRequest failed\n");
|
ok(hr != NULL, "HttpOpenRequest failed\n");
|
||||||
|
|
||||||
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
|
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
|
||||||
@ -1550,14 +1555,14 @@ static void test_http_connection(void)
|
|||||||
if (r != WAIT_OBJECT_0)
|
if (r != WAIT_OBJECT_0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
test_basic_request(si.port, "/test1");
|
test_basic_request(si.port, "GET", "/test1");
|
||||||
test_proxy_indirect(si.port);
|
test_proxy_indirect(si.port);
|
||||||
test_proxy_direct(si.port);
|
test_proxy_direct(si.port);
|
||||||
test_header_handling_order(si.port);
|
test_header_handling_order(si.port);
|
||||||
test_basic_request(si.port, "/test5");
|
test_basic_request(si.port, "POST", "/test5");
|
||||||
|
|
||||||
/* send the basic request again to shutdown the server thread */
|
/* send the basic request again to shutdown the server thread */
|
||||||
test_basic_request(si.port, "/quit");
|
test_basic_request(si.port, "GET", "/quit");
|
||||||
|
|
||||||
r = WaitForSingleObject(hThread, 3000);
|
r = WaitForSingleObject(hThread, 3000);
|
||||||
ok( r == WAIT_OBJECT_0, "thread wait failed\n");
|
ok( r == WAIT_OBJECT_0, "thread wait failed\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user