This commit is contained in:
yhirose 2019-11-27 12:54:01 -05:00
parent 8f3dbf7f21
commit 880f7fa62b
2 changed files with 16 additions and 1 deletions

View file

@ -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:

View file

@ -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) {