std.http.Class: classify out-of-range codes as server_error

RFC 9110 section 15:
Values outside the range 100..599 are invalid. Implementations often use
three-digit integer values outside of that range (i.e., 600..999) for
internal communication of non-HTTP status (e.g., library errors). A
client that receives a response with an invalid status code SHOULD
process the response as if it had a 5xx (Server Error) status code.
This commit is contained in:
Andrew Kelley 2023-01-05 13:31:26 -07:00
parent ba1e53f116
commit 450f3bc925

View File

@ -218,7 +218,6 @@ pub const Status = enum(u10) {
}
pub const Class = enum {
nonstandard,
informational,
success,
redirect,
@ -232,8 +231,7 @@ pub const Status = enum(u10) {
200...299 => .success,
300...399 => .redirect,
400...499 => .client_error,
500...599 => .server_error,
else => .nonstandard,
else => .server_error,
};
}