mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fix UB when HttpStatus code is not one in the enum.
PiperOrigin-RevId: 736244405
This commit is contained in:
committed by
Copybara-Service
parent
b62b56c75e
commit
5da86f5a72
@@ -109,6 +109,8 @@ absl::string_view GetHttpReasonPhrase(HttpStatusCode code) {
|
||||
return "Gateway Timeout";
|
||||
case HttpStatusCode::kHttpVersionNotSupported:
|
||||
return "HTTP Version Not Supported";
|
||||
default:
|
||||
return "Unknown HTTP status code";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,8 @@ TEST(HttpStatusCode, TestReturnCorrectReasonPhrase) {
|
||||
"HTTP Version Not Supported");
|
||||
EXPECT_EQ(GetHttpReasonPhrase(HttpStatusCode::kHttpRequestUriTooLong),
|
||||
"Request-URI Too Long");
|
||||
EXPECT_EQ(GetHttpReasonPhrase(static_cast<HttpStatusCode>(600)),
|
||||
"Unknown HTTP status code");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user