pub struct Status(/* private fields */);Expand description
A response status code (RFC 9110 §15).
Three decimal digits and nothing more: :status carries the code alone
(RFC 9114 §4.3.2), and the reason phrase that followed it in HTTP/1.1 has no
HTTP/3 representation at all. The digits are what is stored, because they are
what goes on the wire.
Only the codes this server sends have names. A code with no constant here is one no path reaches, and adding one is how a new answer gets named rather than spelled as a literal at the place it is sent from.
Implementations§
Source§impl Status
impl Status
Sourcepub const BAD_REQUEST: Self
pub const BAD_REQUEST: Self
400 Bad Request: the request is not one this proxy can act on.
Sourcepub const PROXY_AUTHENTICATION_REQUIRED: Self
pub const PROXY_AUTHENTICATION_REQUIRED: Self
407 Proxy Authentication Required (RFC 9110 §15.5.8).
Sourcepub const REQUEST_HEADER_FIELDS_TOO_LARGE: Self
pub const REQUEST_HEADER_FIELDS_TOO_LARGE: Self
431 Request Header Fields Too Large (RFC 6585 §5, RFC 9114 §4.2.2).
Sourcepub const INTERNAL_SERVER_ERROR: Self
pub const INTERNAL_SERVER_ERROR: Self
500 Internal Server Error: a fault on this side of the tunnel.
Sourcepub const NOT_IMPLEMENTED: Self
pub const NOT_IMPLEMENTED: Self
501 Not Implemented: a method or :protocol this proxy does not serve.
Sourcepub const BAD_GATEWAY: Self
pub const BAD_GATEWAY: Self
502 Bad Gateway: the target refused the connection or could not be looked up (RFC 9209 §2.3.2).
Sourcepub const SERVICE_UNAVAILABLE: Self
pub const SERVICE_UNAVAILABLE: Self
503 Service Unavailable: the target could not be reached at all, or this proxy is at a limit (RFC 9209 §2.3.2).
Sourcepub const GATEWAY_TIMEOUT: Self
pub const GATEWAY_TIMEOUT: Self
504 Gateway Timeout: the target never answered (RFC 9209 §2.3.2).
Sourcepub fn parse(bytes: &[u8]) -> Option<Self>
pub fn parse(bytes: &[u8]) -> Option<Self>
Reads a :status value.
None for anything that is not three digits with a non-zero first one,
which is the shape of every code RFC 9110 §15 defines.
A server reads no responses, so this exists for the suite’s client. It is here rather than there because a status is a status at both ends of the wire.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
The three digits, as :status carries them.
§Panics
Never in practice: every constant here is an ASCII literal and
Self::parse accepts nothing else, so the digits cannot be anything a
str will not hold. The check is kept rather than made unchecked
because it costs three comparisons on a path that writes a response.