@@ -3839,9 +3839,12 @@ TEST(MountTest, Unmount) {
38393839TEST (ExceptionTest, ThrowExceptionInHandler) {
38403840 Server svr;
38413841
3842- svr.Get (" /hi " , [&](const Request & /* req*/ , Response & /* res*/ ) {
3842+ svr.Get (" /exception " , [&](const Request & /* req*/ , Response & /* res*/ ) {
38433843 throw std::runtime_error (" exception..." );
3844- // res.set_content("Hello World!", "text/plain");
3844+ });
3845+
3846+ svr.Get (" /unknown" , [&](const Request & /* req*/ , Response & /* res*/ ) {
3847+ throw std::runtime_error (" exception\r\n ..." );
38453848 });
38463849
38473850 auto listen_thread = std::thread ([&svr]() { svr.listen (" localhost" , PORT); });
@@ -3854,11 +3857,21 @@ TEST(ExceptionTest, ThrowExceptionInHandler) {
38543857
38553858 Client cli (" localhost" , PORT);
38563859
3857- auto res = cli.Get (" /hi" );
3858- ASSERT_TRUE (res);
3859- EXPECT_EQ (500 , res->status );
3860- ASSERT_TRUE (res->has_header (" EXCEPTION_WHAT" ));
3861- EXPECT_EQ (" exception..." , res->get_header_value (" EXCEPTION_WHAT" ));
3860+ {
3861+ auto res = cli.Get (" /exception" );
3862+ ASSERT_TRUE (res);
3863+ EXPECT_EQ (500 , res->status );
3864+ ASSERT_TRUE (res->has_header (" EXCEPTION_WHAT" ));
3865+ EXPECT_EQ (" exception..." , res->get_header_value (" EXCEPTION_WHAT" ));
3866+ }
3867+
3868+ {
3869+ auto res = cli.Get (" /unknown" );
3870+ ASSERT_TRUE (res);
3871+ EXPECT_EQ (500 , res->status );
3872+ ASSERT_TRUE (res->has_header (" EXCEPTION_WHAT" ));
3873+ EXPECT_EQ (" exception\\ r\\ n..." , res->get_header_value (" EXCEPTION_WHAT" ));
3874+ }
38623875
38633876 svr.stop ();
38643877 listen_thread.join ();
0 commit comments