@@ -3839,9 +3839,12 @@ TEST(MountTest, Unmount) {
3839
3839
TEST (ExceptionTest, ThrowExceptionInHandler) {
3840
3840
Server svr;
3841
3841
3842
- svr.Get (" /hi " , [&](const Request & /* req*/ , Response & /* res*/ ) {
3842
+ svr.Get (" /exception " , [&](const Request & /* req*/ , Response & /* res*/ ) {
3843
3843
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 ..." );
3845
3848
});
3846
3849
3847
3850
auto listen_thread = std::thread ([&svr]() { svr.listen (" localhost" , PORT); });
@@ -3854,11 +3857,21 @@ TEST(ExceptionTest, ThrowExceptionInHandler) {
3854
3857
3855
3858
Client cli (" localhost" , PORT);
3856
3859
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
+ }
3862
3875
3863
3876
svr.stop ();
3864
3877
listen_thread.join ();
0 commit comments