Merge commit from fork

This commit is contained in:
yhirose authored and GitHub committed 2026-02-27 21:35:32 -05:00
1 parent c6c75e4c69
commit defd907c74
2 files changed
+2 -15

No files matched your search

-11
View File
@@ -11739,16 +11739,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
routed = true; routed = true;
} else { } else {
res.status = StatusCode::InternalServerError_500; res.status = StatusCode::InternalServerError_500;
std::string val;
auto s = e.what();
for (size_t i = 0; s[i]; i++) {
switch (s[i]) {
case '\r': val += "\\r"; break;
case '\n': val += "\\n"; break;
default: val += s[i]; break;
}
}
res.set_header("EXCEPTION_WHAT", val);
} }
} catch (...) { } catch (...) {
if (exception_handler_) { if (exception_handler_) {
@@ -11757,7 +11747,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
routed = true; routed = true;
} else { } else {
res.status = StatusCode::InternalServerError_500; res.status = StatusCode::InternalServerError_500;
res.set_header("EXCEPTION_WHAT", "UNKNOWN");
} }
} }
#endif #endif
+2 -4
View File
@@ -2701,16 +2701,14 @@ TEST(ExceptionTest, WithoutExceptionHandler) {
auto res = cli.Get("/exception"); auto res = cli.Get("/exception");
ASSERT_TRUE(res); ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::InternalServerError_500, res->status); EXPECT_EQ(StatusCode::InternalServerError_500, res->status);
ASSERT_TRUE(res->has_header("EXCEPTION_WHAT")); EXPECT_FALSE(res->has_header("EXCEPTION_WHAT"));
EXPECT_EQ("exception...", res->get_header_value("EXCEPTION_WHAT"));
} }
{ {
auto res = cli.Get("/unknown"); auto res = cli.Get("/unknown");
ASSERT_TRUE(res); ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::InternalServerError_500, res->status); EXPECT_EQ(StatusCode::InternalServerError_500, res->status);
ASSERT_TRUE(res->has_header("EXCEPTION_WHAT")); EXPECT_FALSE(res->has_header("EXCEPTION_WHAT"));
EXPECT_EQ("exception\\r\\n...", res->get_header_value("EXCEPTION_WHAT"));
} }
} }