diff --git a/httplib.h b/httplib.h
index d6df1cf..3bad9f6 100644
--- a/httplib.h
+++ b/httplib.h
@@ -1475,7 +1475,7 @@ public:
       if (!callback(buff.data(), buff.size() - strm.avail_out)) { return false; }
     } while (strm.avail_out == 0);
 
-    return ret == Z_STREAM_END;
+    return ret == Z_OK || ret == Z_STREAM_END;
   }
 
 private:
diff --git a/test/test.cc b/test/test.cc
index fe3321f..5cbd36b 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -28,6 +28,8 @@ const string LONG_QUERY_URL = "/long-query-value?key=" + LONG_QUERY_VALUE;
 
 const std::string JSON_DATA = "{\"hello\":\"world\"}";
 
+const string LARGE_DATA = string(1024 * 1024 * 100, '@'); // 100MB
+
 #ifdef _WIN32
 TEST(StartupTest, WSAStartup) {
   WSADATA wsaData;
@@ -708,6 +710,11 @@ protected:
                EXPECT_EQ(req.body, "PUT");
                res.set_content(req.body, "text/plain");
              })
+        .Put("/put-large",
+             [&](const Request &req, Response &res) {
+               EXPECT_EQ(req.body, LARGE_DATA);
+               res.set_content(req.body, "text/plain");
+             })
         .Patch("/patch",
                [&](const Request &req, Response &res) {
                  EXPECT_EQ(req.body, "PATCH");
@@ -1418,6 +1425,14 @@ TEST_F(ServerTest, PutWithContentProviderWithGzip) {
   EXPECT_EQ(200, res->status);
   EXPECT_EQ("PUT", res->body);
 }
+
+TEST_F(ServerTest, PutLargeFileWithGzip) {
+  auto res = cli_.Put("/put-large", LARGE_DATA, "text/plain", true);
+
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
+  EXPECT_EQ(LARGE_DATA, res->body);
+}
 #endif
 
 TEST_F(ServerTest, Patch) {