[PATCH 2/2] wininet: Decoding is enabled by default

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Fri Sep 3 23:37:14 CDT 2021


Unless explicitly turned off decoding of gzip, deflate is supported.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47505

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/wininet/internet.c   |  1 +
 dlls/wininet/internet.h   |  2 +-
 dlls/wininet/tests/http.c | 62 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index cef151c7bf2..4ac66660aa3 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -107,6 +107,7 @@ void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t si
     if(!ret)
         return NULL;
 
+    ret->decoding = -1;
     list_init(&ret->children);
 
     EnterCriticalSection( &WININET_cs );
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index e9d68e2c2d9..462c7a47635 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -283,7 +283,7 @@ struct _object_header_t
     ULONG  ErrorMask;
     DWORD  dwInternalFlags;
     LONG   refs;
-    BOOL   decoding;
+    INT    decoding;
     INTERNET_STATUS_CALLBACK lpfnStatusCB;
     struct list entry;
     struct list children;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index d32f01be2c5..ed35025d5f4 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -3523,6 +3523,67 @@ static void test_not_modified(int port)
     InternetCloseHandle(ses);
 }
 
+static void test_deflate(int port)
+{
+    DWORD len;
+    char buf[256];
+    HINTERNET ses, con, req;
+    BOOL ret;
+    BOOL b;
+    char binary[] = "\x1f\x8b\x08";
+    char text[] = "<!DOCTYPE HTML PUBLIC";
+
+    ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+    ok(ses != NULL, "InternetOpen failed\n");
+
+    con = InternetConnectA(ses, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(con != NULL, "InternetConnect failed\n");
+
+    /* Default Decoding */
+    req = HttpOpenRequestA(con, NULL, "/tests/gzip.php", NULL, NULL, NULL, 0, 0);
+    ok(req != NULL, "HttpOpenRequest failed\n");
+
+    SetLastError(0xdeadbeef);
+    ret = HttpSendRequestW(req, L"Accept-Encoding: gzip, deflate", ~0u, NULL, 0);
+    ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+    test_status_code(req, 200);
+
+    len = sizeof(buf)-1;
+    ret = HttpQueryInfoA(req, HTTP_QUERY_CONTENT_LENGTH, buf, &len, 0);
+    ok(!ret, "HttpQueryInfo should have failed\n");
+    ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND , "got %u\n", GetLastError());
+
+    ret = InternetReadFile(req, buf, 256, &len);
+    ok(ret, "InternetReadFile failed %d\n", GetLastError());
+    ok(!strncmp(buf, text, strlen(text)), "got %s\n", debugstr_a(buf));
+
+    InternetCloseHandle(req);
+    InternetCloseHandle(con);
+
+    /* Disabled Decoding */
+    b = FALSE;
+    InternetSetOptionA(ses, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
+
+    con = InternetConnectA(ses, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(con != NULL, "InternetConnect failed\n");
+
+    req = HttpOpenRequestA(con, NULL, "/tests/gzip.php", NULL, NULL, NULL, 0, 0);
+    ok(req != NULL, "HttpOpenRequest failed\n");
+
+    SetLastError(0xdeadbeef);
+    ret = HttpSendRequestW(req, L"Accept-Encoding: gzip, deflate", ~0u, NULL, 0);
+    ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+    test_status_code(req, 200);
+
+    ret = InternetReadFile(req, buf, 256, &len);
+    ok(ret, "InternetReadFile failed %d\n", GetLastError());
+    ok(!strncmp(buf, binary, strlen(binary)), "got %s\n", debugstr_a(buf));
+
+    InternetCloseHandle(req);
+    InternetCloseHandle(con);
+    InternetCloseHandle(ses);
+}
+
 static void test_conn_close(int port)
 {
     HINTERNET session, connection, req;
@@ -6097,6 +6158,7 @@ static void test_http_connection(void)
     test_options(si.port);
     test_no_content(si.port);
     test_not_modified(si.port);
+    test_deflate(si.port);
     test_conn_close(si.port);
     test_no_cache(si.port);
     test_cache_read_gzipped(si.port);
-- 
2.33.0




More information about the wine-devel mailing list