Skip to content

Commit aa54324

Browse files
committed
Added test for post request with query string and body
1 parent 5675cad commit aa54324

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ class ServerTest : public ::testing::Test {
904904
EXPECT_EQ(body, "content");
905905
res.set_content(body, "text/plain");
906906
})
907+
.Post("/query-string-and-body",
908+
[&](const Request &req, Response & /*res*/) {
909+
ASSERT_TRUE(req.has_param("key"));
910+
EXPECT_EQ(req.get_param_value("key"), "value");
911+
EXPECT_EQ(req.body, "content");
912+
})
907913
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
908914
.Get("/gzip",
909915
[&](const Request & /*req*/, Response &res) {
@@ -1674,6 +1680,12 @@ TEST_F(ServerTest, PatchContentReceiver) {
16741680
ASSERT_EQ("content", res->body);
16751681
}
16761682

1683+
TEST_F(ServerTest, PostQueryStringAndBody) {
1684+
auto res = cli_.Post("/query-string-and-body?key=value", "content", "text/plain");
1685+
ASSERT_TRUE(res != nullptr);
1686+
ASSERT_EQ(200, res->status);
1687+
}
1688+
16771689
TEST_F(ServerTest, HTTP2Magic) {
16781690
Request req;
16791691
req.method = "PRI";
@@ -1686,6 +1698,7 @@ TEST_F(ServerTest, HTTP2Magic) {
16861698
ASSERT_TRUE(ret);
16871699
EXPECT_EQ(400, res->status);
16881700
}
1701+
16891702
TEST_F(ServerTest, KeepAlive) {
16901703
cli_.set_keep_alive_max_count(4);
16911704

0 commit comments

Comments
 (0)