Expand description
The HTTP status code registry: a named constant for every registered code, the canonical reason phrases, and status classes.
Status codes are plain u16 values throughout the crate; these
constants give them names. The registry is the IANA HTTP Status Code
Registry, with the names RFC 9110 section 15 uses (413 Content Too Large, 422 Unprocessable Content). 306 and 418 are reserved and
unused there, so they have no constant and no phrase.
§Examples
use http_net::{Response, reason_phrase, status};
let r = Response::new(status::NO_CONTENT);
assert_eq!(r.status(), 204);
assert_eq!(reason_phrase(status::TOO_EARLY), "Too Early");
assert_eq!(status::REQUEST_HEADER_FIELDS_TOO_LARGE, 431);Enums§
- Status
Class - The class of a status code (RFC 9110 section 15).
Constants§
- ACCEPTED
202 Accepted- ALREADY_
REPORTED 208 Already Reported- BAD_
GATEWAY 502 Bad Gateway- BAD_
REQUEST 400 Bad Request- CONFLICT
409 Conflict- CONTENT_
TOO_ LARGE 413 Content Too Large- CONTINUE
100 Continue- CREATED
201 Created- EARLY_
HINTS 103 Early Hints- EXPECTATION_
FAILED 417 Expectation Failed- FAILED_
DEPENDENCY 424 Failed Dependency- FORBIDDEN
403 Forbidden- FOUND
302 Found- GATEWAY_
TIMEOUT 504 Gateway Timeout- GONE
410 Gone- HTTP_
VERSION_ NOT_ SUPPORTED 505 HTTP Version Not Supported- IM_USED
226 IM Used- INSUFFICIENT_
STORAGE 507 Insufficient Storage- INTERNAL_
SERVER_ ERROR 500 Internal Server Error- LENGTH_
REQUIRED 411 Length Required- LOCKED
423 Locked- LOOP_
DETECTED 508 Loop Detected- METHOD_
NOT_ ALLOWED 405 Method Not Allowed- MISDIRECTED_
REQUEST 421 Misdirected Request- MOVED_
PERMANENTLY 301 Moved Permanently- MULTIPLE_
CHOICES 300 Multiple Choices- MULTI_
STATUS 207 Multi-Status- NETWORK_
AUTHENTICATION_ REQUIRED 511 Network Authentication Required- NON_
AUTHORITATIVE_ INFORMATION 203 Non-Authoritative Information- NOT_
ACCEPTABLE 406 Not Acceptable- NOT_
EXTENDED 510 Not Extended- NOT_
FOUND 404 Not Found- NOT_
IMPLEMENTED 501 Not Implemented- NOT_
MODIFIED 304 Not Modified- NO_
CONTENT 204 No Content- OK
200 OK- PARTIAL_
CONTENT 206 Partial Content- PAYMENT_
REQUIRED 402 Payment Required- PERMANENT_
REDIRECT 308 Permanent Redirect- PRECONDITION_
FAILED 412 Precondition Failed- PRECONDITION_
REQUIRED 428 Precondition Required- PROCESSING
102 Processing- PROXY_
AUTHENTICATION_ REQUIRED 407 Proxy Authentication Required- RANGE_
NOT_ SATISFIABLE 416 Range Not Satisfiable- REQUEST_
HEADER_ FIELDS_ TOO_ LARGE 431 Request Header Fields Too Large- REQUEST_
TIMEOUT 408 Request Timeout- RESET_
CONTENT 205 Reset Content- SEE_
OTHER 303 See Other- SERVICE_
UNAVAILABLE 503 Service Unavailable- SWITCHING_
PROTOCOLS 101 Switching Protocols- TEMPORARY_
REDIRECT 307 Temporary Redirect- TOO_
EARLY 425 Too Early- TOO_
MANY_ REQUESTS 429 Too Many Requests- UNAUTHORIZED
401 Unauthorized- UNAVAILABLE_
FOR_ LEGAL_ REASONS 451 Unavailable For Legal Reasons- UNPROCESSABLE_
CONTENT 422 Unprocessable Content- UNSUPPORTED_
MEDIA_ TYPE 415 Unsupported Media Type- UPGRADE_
REQUIRED 426 Upgrade Required- URI_
TOO_ LONG 414 URI Too Long- USE_
PROXY 305 Use Proxy- VARIANT_
ALSO_ NEGOTIATES 506 Variant Also Negotiates
Functions§
- reason_
phrase - The canonical reason phrase for a status code: every code in
the IANA HTTP Status Code Registry, with the RFC 9110 names;
""for an unassigned code and for the reserved306and418. - status_
allows_ body - Whether a response with
statusto a request withrequestmethod can carry a body (RFC 9112 section 6.3, rules 1 and 2): false for 1xx, 204, 304, any response toHEAD, and a 2xx toCONNECT(which turns the connection into a tunnel). For proxies and clients deciding how to read or forward a response. - status_
class - The class of
status, orNoneoutside100..=599.