From 282f2feb77088ab905e2da5ae2e22a6d4d99a992 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 1 Feb 2025 22:11:15 -0500 Subject: [PATCH] Add a unit test --- test/test.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test.cc b/test/test.cc index 5372832..bfbf992 100644 --- a/test/test.cc +++ b/test/test.cc @@ -1863,6 +1863,32 @@ TEST(PathUrlEncodeTest, PathUrlEncode) { } } +TEST(PathUrlEncodeTest, IncludePercentEncodingLF) { + Server svr; + + svr.Get("/", [](const Request &req, Response &res) { + EXPECT_EQ("\x0A", req.get_param_value("something")); + }); + + auto thread = std::thread([&]() { svr.listen(HOST, PORT); }); + auto se = detail::scope_exit([&] { + svr.stop(); + thread.join(); + ASSERT_FALSE(svr.is_running()); + }); + + svr.wait_until_ready(); + + { + Client cli(HOST, PORT); + cli.set_url_encode(false); + + auto res = cli.Get("/?something=%0A"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + } +} + TEST(BindServerTest, DISABLED_BindDualStack) { Server svr;