Merge commit from fork

This commit is contained in:
yhirose
2026-02-27 21:35:32 -05:00
committed by GitHub
parent c6c75e4c69
commit defd907c74
2 changed files with 2 additions and 15 deletions
-11
View File
@@ -11739,16 +11739,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
routed = true;
} else {
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 (...) {
if (exception_handler_) {
@@ -11757,7 +11747,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
routed = true;
} else {
res.status = StatusCode::InternalServerError_500;
res.set_header("EXCEPTION_WHAT", "UNKNOWN");
}
}
#endif
+2 -4
View File
@@ -2701,16 +2701,14 @@ TEST(ExceptionTest, WithoutExceptionHandler) {
auto res = cli.Get("/exception");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::InternalServerError_500, res->status);
ASSERT_TRUE(res->has_header("EXCEPTION_WHAT"));
EXPECT_EQ("exception...", res->get_header_value("EXCEPTION_WHAT"));
EXPECT_FALSE(res->has_header("EXCEPTION_WHAT"));
}
{
auto res = cli.Get("/unknown");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::InternalServerError_500, res->status);
ASSERT_TRUE(res->has_header("EXCEPTION_WHAT"));
EXPECT_EQ("exception\\r\\n...", res->get_header_value("EXCEPTION_WHAT"));
EXPECT_FALSE(res->has_header("EXCEPTION_WHAT"));
}
}