Skip to main content

Module status

Module status 

Source
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§

StatusClass
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 reserved 306 and 418.
status_allows_body
Whether a response with status to a request with request method can carry a body (RFC 9112 section 6.3, rules 1 and 2): false for 1xx, 204, 304, any response to HEAD, and a 2xx to CONNECT (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, or None outside 100..=599.