This commit is contained in:
yhirose 2017-12-03 22:31:00 -05:00
parent 3dded8c3e3
commit 4fb2f51766
2 changed files with 56 additions and 24 deletions

View file

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