wininet: Allow Accept-Encoding for HTTP/1.0 requests.

This commit is contained in:
Michael Müller 2014-12-08 02:51:30 +01:00 committed by Alexandre Julliard
parent 93f40b2ecc
commit 7c8df7eb5e
2 changed files with 47 additions and 21 deletions

View File

@ -205,7 +205,6 @@ static LPWSTR HTTP_build_req( LPCWSTR *list, int len );
static DWORD HTTP_HttpQueryInfoW(http_request_t*, DWORD, LPVOID, LPDWORD, LPDWORD);
static LPWSTR HTTP_GetRedirectURL(http_request_t *req, LPCWSTR lpszUrl);
static UINT HTTP_DecodeBase64(LPCWSTR base64, LPSTR bin);
static BOOL HTTP_VerifyValidHeader(http_request_t *req, LPCWSTR field);
static BOOL drain_content(http_request_t*,BOOL);
static CRITICAL_SECTION connection_pool_cs;
@ -1312,10 +1311,8 @@ static DWORD HTTP_HttpAddRequestHeadersW(http_request_t *request,
pFieldAndValue = HTTP_InterpretHttpHeader(lpszStart);
if (pFieldAndValue)
{
res = HTTP_VerifyValidHeader(request, pFieldAndValue[0]);
if (res == ERROR_SUCCESS)
res = HTTP_ProcessHeader(request, pFieldAndValue[0],
pFieldAndValue[1], dwModifier | HTTP_ADDHDR_FLAG_REQ);
res = HTTP_ProcessHeader(request, pFieldAndValue[0],
pFieldAndValue[1], dwModifier | HTTP_ADDHDR_FLAG_REQ);
HTTP_FreeTokens(pFieldAndValue);
}
@ -6308,21 +6305,6 @@ static BOOL HTTP_DeleteCustomHeader(http_request_t *request, DWORD index)
}
/***********************************************************************
* HTTP_VerifyValidHeader (internal)
*
* Verify the given header is not invalid for the given http request
*
*/
static BOOL HTTP_VerifyValidHeader(http_request_t *request, LPCWSTR field)
{
/* Accept-Encoding is stripped from HTTP/1.0 requests. It is invalid */
if (!strcmpW(request->version, g_szHttp1_0) && !strcmpiW(field, szAccept_Encoding))
return ERROR_HTTP_INVALID_HEADER;
return ERROR_SUCCESS;
}
/***********************************************************************
* IsHostInProxyBypassList (@)
*

View File

@ -2314,7 +2314,13 @@ static DWORD CALLBACK server_thread(LPVOID param)
}
if (strstr(buffer, "GET /test_premature_disconnect"))
trace("closing connection\n");
if (strstr(buffer, "/test_accept_encoding_http10"))
{
if (strstr(buffer, "Accept-Encoding: gzip"))
send(c, okmsg, sizeof okmsg-1, 0);
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
shutdown(c, 2);
closesocket(c);
c = -1;
@ -4169,6 +4175,43 @@ static void test_request_content_length(int port)
CloseHandle(hCompleteEvent);
}
static void test_accept_encoding(int port)
{
HINTERNET ses, con, req;
BOOL ret;
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
req = HttpOpenRequestA(con, "GET", "/test_accept_encoding_http10", "HTTP/1.0", NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpAddRequestHeadersA(req, "Accept-Encoding: gzip\r\n", ~0u, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
ok(ret, "HttpAddRequestHeaders failed\n");
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequestA failed\n");
test_status_code(req, 200);
InternetCloseHandle(req);
req = HttpOpenRequestA(con, "GET", "/test_accept_encoding_http10", "HTTP/1.0", NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, "Accept-Encoding: gzip", ~0u, NULL, 0);
ok(ret, "HttpSendRequestA failed\n");
test_status_code(req, 200);
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
}
static void test_http_connection(void)
{
struct server_info si;
@ -4215,6 +4258,7 @@ static void test_http_connection(void)
test_successive_HttpSendRequest(si.port);
test_head_request(si.port);
test_request_content_length(si.port);
test_accept_encoding(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");