#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum StatusCode {
Continue,
SwitchingProtocols,
Ok,
Created,
Accepted,
NonAuthoritativeInformation,
NoContent,
ResetContent,
PartialContent,
MultipleChoices,
MovedPermanently,
Found,
SeeOther,
NotModified,
TemporaryRedirect,
PermanentRedirect,
BadRequest,
Unauthorized,
Forbidden,
NotFound,
MethodNotAllowed,
NotAcceptable,
ProxyAuthenticationRequired,
RequestTimeout,
Conflict,
Gone,
LenghtRequired,
PreconditionFailed,
PayloadTooLarge,
URITooLong,
UnsupportedMediaType,
RangeNotSatisfiable,
ExpectationFailed,
ImATeapot,
UpgradeRequired,
PreconditionRequired,
TooManyRequests,
RequestHeaderFieldsTooLarge,
UnavailableForLegalReasons,
InternalServerError,
NotImplemented,
BadGateway,
ServiceUnavailable,
GatewayTimeout,
HTTPVersionNotSupported,
VariantAlsoNegotiates,
NotExtended,
NetworkAuthenticationRequired,
}
impl StatusCode {
pub fn to_string(&self) -> String {
match self {
StatusCode::Continue => String::from("HTTP/1.1 100 Continue"),
StatusCode::SwitchingProtocols => String::from("HTTP/1.1 101 Switching Protocols"),
StatusCode::Ok => String::from("HTTP/1.1 200 OK"),
StatusCode::Created => String::from("HTTP/1.1 201 Created"),
StatusCode::Accepted => String::from("HTTP/1.1 202 Accepted"),
StatusCode::NonAuthoritativeInformation => {
String::from("HTTP/1.1 203 Non-Authorative Information")
}
StatusCode::NoContent => String::from("HTTP/1.1 204 No Content"),
StatusCode::ResetContent => String::from("HTTP/1.1 205 Reset Content"),
StatusCode::PartialContent => String::from("HTTP/1.1 206 Partial Content"),
StatusCode::MultipleChoices => String::from("HTTP/1.1 300 Multiple Choices"),
StatusCode::MovedPermanently => String::from("HTTP/1.1 301 Moved Permanently"),
StatusCode::Found => String::from("HTTP/1.1 302 Found"),
StatusCode::SeeOther => String::from("HTTP/1.1 303 See Other"),
StatusCode::NotModified => String::from("HTTP/1.1 304 Not Modified"),
StatusCode::TemporaryRedirect => String::from("HTTP/1.1 307 Temporary Redirect"),
StatusCode::PermanentRedirect => String::from("HTTP/1.1 308 Permanent Redirect"),
StatusCode::BadRequest => String::from("HTTP/1.1 400 Bad Request"),
StatusCode::Unauthorized => String::from("HTTP/1.1 401 Unauthorized"),
StatusCode::Forbidden => String::from("HTTP/1.1 403 Forbidden"),
StatusCode::NotFound => String::from("HTTP/1.1 404 Not Found"),
StatusCode::MethodNotAllowed => String::from("HTTP/1.1 405 Method Not Allowed"),
StatusCode::NotAcceptable => String::from("HTTP/1.1 406 Not Acceptable"),
StatusCode::ProxyAuthenticationRequired => {
String::from("HTTP/1.1 407 Proxy Authentication Required")
}
StatusCode::RequestTimeout => String::from("HTTP/1.1 408 Request Timeout"),
StatusCode::Conflict => String::from("HTTP/1.1 409 Conflict"),
StatusCode::Gone => String::from("HTTP/1.1 410 Gone"),
StatusCode::LenghtRequired => String::from("HTTP/1.1 411 Lenght Required"),
StatusCode::PreconditionFailed => String::from("HTTP/1.1 412 Precondition Failed"),
StatusCode::PayloadTooLarge => String::from("HTTP/1.1 413 Payload Too Large"),
StatusCode::URITooLong => String::from("HTTP/1.1 313 URI Too Long"),
StatusCode::UnsupportedMediaType => String::from("HTTP/1.1 415 Unsupported Media Type"),
StatusCode::RangeNotSatisfiable => String::from("HTTP/1.1 416 Range Not Satisfiable"),
StatusCode::ExpectationFailed => String::from("HTTP/1.1 417 Expectation Failed"),
StatusCode::ImATeapot => String::from("HTTP/1.1 418 I'm a teapot"),
StatusCode::UpgradeRequired => String::from("HTTP/1.1 426 Upgrade Required"),
StatusCode::PreconditionRequired => String::from("HTTP/1.1 428 Precondition Required"),
StatusCode::TooManyRequests => String::from("HTTP/1.1 429 Too Many Requests"),
StatusCode::RequestHeaderFieldsTooLarge => {
String::from("HTTP/1.1 431 Request Header Fields Too Large")
}
StatusCode::UnavailableForLegalReasons => {
String::from("HTTP/1.1 451 Unavailable For Legal Reasons")
}
StatusCode::InternalServerError => String::from("HTTP/1.1 500 Internal Server Error"),
StatusCode::NotImplemented => String::from("HTTP/1.1 501 Not Implemented"),
StatusCode::BadGateway => String::from("HTTP/1.1 502 Bad Gateway"),
StatusCode::ServiceUnavailable => String::from("HTTP/1.1 503 Service Unavailable"),
StatusCode::GatewayTimeout => String::from("HTTP/1.1 504 Gateway Timeout"),
StatusCode::HTTPVersionNotSupported => {
String::from("HTTP/1.1 505 HTTP Version Not Supported")
}
StatusCode::VariantAlsoNegotiates => {
String::from("HTTP/1.1 506 Variant Also Negotiates")
}
StatusCode::NotExtended => String::from("HTTP/1.1 510 Not Extended"),
StatusCode::NetworkAuthenticationRequired => {
String::from("HTTP/1.1 511 Network Authentication Required")
}
}
}
}