=?UTF-8?Q?Michael=20M=C3=BCller=20?=: wininet: Allow Accept-Encoding for HTTP/1.0 requests.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Feb 24 10:33:23 CST 2015


Module: wine
Branch: master
Commit: 7c8df7eb5e2eaf7db7bc71b0c1dfa455edb3200e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7c8df7eb5e2eaf7db7bc71b0c1dfa455edb3200e

Author: Michael Müller <michael at fds-team.de>
Date:   Mon Dec  8 02:51:30 2014 +0100

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

---

 dlls/wininet/http.c       | 22 ++--------------------
 dlls/wininet/tests/http.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index d515d7d..c0785b9 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -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);
         }
 
@@ -6309,21 +6306,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 (@)
  *
  * Undocumented
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 92a6b8d..3e66a27 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -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");




More information about the wine-cvs mailing list