Commit 656a0358 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wininet: Don't send a "Connection: Close" header.

parent a6dc4a9a
......@@ -3156,7 +3156,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
INT responseLen;
BOOL loop_next;
INTERNET_ASYNC_RESULT iar;
static const WCHAR szClose[] = { 'C','l','o','s','e',0 };
static const WCHAR szPost[] = { 'P','O','S','T',0 };
static const WCHAR szContentLength[] =
{ 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 };
......@@ -3211,10 +3210,10 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
}
HTTP_FixURL(lpwhr);
HTTP_ProcessHeader(lpwhr, szConnection,
lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION ? szKeepAlive : szClose,
HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE);
if (lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION)
{
HTTP_ProcessHeader(lpwhr, szConnection, szKeepAlive, HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE);
}
HTTP_InsertAuthorization(lpwhr, lpwhr->pAuthInfo, szAuthorization);
HTTP_InsertAuthorization(lpwhr, lpwhr->pProxyAuthInfo, szProxy_Authorization);
......
......@@ -1394,7 +1394,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
buffer[i-3] == '\r' && buffer[i-1] == '\r')
break;
}
if (strstr(buffer, "GET /test1"))
{
if (!strstr(buffer, "Content-Length: 0"))
......@@ -1405,7 +1404,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "/test2"))
{
if (strstr(buffer, "Proxy-Authorization: Basic bWlrZToxMTAx"))
......@@ -1416,7 +1414,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, proxymsg, sizeof proxymsg-1, 0);
}
if (strstr(buffer, "/test3"))
{
if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
......@@ -1424,7 +1421,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, noauthmsg, sizeof noauthmsg-1, 0);
}
if (strstr(buffer, "/test4"))
{
if (strstr(buffer, "Connection: Close"))
......@@ -1432,7 +1428,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "POST /test5"))
{
if (strstr(buffer, "Content-Length: 0"))
......@@ -1443,7 +1438,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "GET /test6"))
{
send(c, contmsg, sizeof contmsg-1, 0);
......@@ -1451,7 +1445,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, okmsg, sizeof okmsg-1, 0);
send(c, page1, sizeof page1-1, 0);
}
if (strstr(buffer, "POST /test7"))
{
if (strstr(buffer, "Content-Length: 100"))
......@@ -1462,7 +1455,22 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "/test8"))
{
if (!strstr(buffer, "Connection: Close") &&
strstr(buffer, "Connection: Keep-Alive"))
send(c, okmsg, sizeof okmsg-1, 0);
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "/test9"))
{
if (!strstr(buffer, "Connection: Close") &&
!strstr(buffer, "Connection: Keep-Alive"))
send(c, okmsg, sizeof okmsg-1, 0);
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "GET /quit"))
{
send(c, okmsg, sizeof okmsg-1, 0);
......@@ -1686,6 +1694,49 @@ static void test_header_handling_order(int port)
InternetCloseHandle(session);
}
static void test_connection_header(int port)
{
HINTERNET ses, con, req;
DWORD size, status;
BOOL ret;
ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
req = HttpOpenRequest(con, NULL, "/test8", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequest(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
status = 0;
size = sizeof(status);
ret = HttpQueryInfo(req, 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(req);
req = HttpOpenRequest(con, NULL, "/test9", NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequest(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
status = 0;
size = sizeof(status);
ret = HttpQueryInfo(req, 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(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
}
static void test_http_connection(void)
{
struct server_info si;
......@@ -1709,6 +1760,7 @@ static void test_http_connection(void)
test_header_handling_order(si.port);
test_basic_request(si.port, "POST", "/test5");
test_basic_request(si.port, "GET", "/test6");
test_connection_header(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
......
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