mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Fixed #19
This commit is contained in:
parent
3dded8c3e3
commit
4fb2f51766
2 changed files with 56 additions and 24 deletions
31
test/test.cc
31
test/test.cc
|
@ -151,6 +151,9 @@ protected:
|
|||
svr_.get("/hi", [&](const Request& /*req*/, Response& res) {
|
||||
res.set_content("Hello World!", "text/plain");
|
||||
})
|
||||
.get("/endwith%", [&](const Request& /*req*/, Response& res) {
|
||||
res.set_content("Hello World!", "text/plain");
|
||||
})
|
||||
.get("/", [&](const Request& /*req*/, Response& res) {
|
||||
res.set_redirect("/hi");
|
||||
})
|
||||
|
@ -427,6 +430,34 @@ TEST_F(ServerTest, TooLongHeader)
|
|||
EXPECT_EQ(400, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, PercentEncoding)
|
||||
{
|
||||
auto res = cli_.get("/e%6edwith%");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, PercentEncodingUnicode)
|
||||
{
|
||||
auto res = cli_.get("/e%u006edwith%");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, InvalidPercentEncoding)
|
||||
{
|
||||
auto res = cli_.get("/%endwith%");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(404, res->status);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, InvalidPercentEncodingUnicode)
|
||||
{
|
||||
auto res = cli_.get("/%uendwith%");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(404, res->status);
|
||||
}
|
||||
|
||||
class ServerTestWithAI_PASSIVE : public ::testing::Test {
|
||||
protected:
|
||||
ServerTestWithAI_PASSIVE()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue