mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fix #273
This commit is contained in:
parent
8f3dbf7f21
commit
880f7fa62b
2 changed files with 16 additions and 1 deletions
|
@ -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:
|
||||
|
|
15
test/test.cc
15
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) {
|
||||
|
|
Loading…
Reference in a new issue