mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-17 10:59:39 +00:00
Fix #2379
This commit is contained in:
1 parent
c99d7472b5
commit
0853ce7753
2 files changed
+69
-15
No files matched your search
@@ -3887,6 +3887,13 @@ protected:
|
||||
"01234567890123456789012345678901234567890",
|
||||
"text/plain");
|
||||
})
|
||||
.Get("/compress-with-charset",
|
||||
[&](const Request & /*req*/, Response &res) {
|
||||
res.set_content(
|
||||
"12345678901234567890123456789012345678901234567890123456789"
|
||||
"01234567890123456789012345678901234567890",
|
||||
"application/json; charset=utf-8");
|
||||
})
|
||||
.Get("/nocompress",
|
||||
[&](const Request & /*req*/, Response &res) {
|
||||
res.set_content(
|
||||
@@ -6247,6 +6254,21 @@ TEST_F(ServerTest, Gzip) {
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, GzipWithContentTypeParameters) {
|
||||
Headers headers;
|
||||
headers.emplace("Accept-Encoding", "gzip, deflate");
|
||||
auto res = cli_.Get("/compress-with-charset", headers);
|
||||
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ("gzip", res->get_header_value("Content-Encoding"));
|
||||
EXPECT_EQ("application/json; charset=utf-8",
|
||||
res->get_header_value("Content-Type"));
|
||||
EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456"
|
||||
"7890123456789012345678901234567890",
|
||||
res->body);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, GzipWithoutAcceptEncoding) {
|
||||
Headers headers;
|
||||
headers.emplace("Accept-Encoding", "");
|
||||
|
||||
Reference in new issue
Block a user