Net.HTTP.Status

lib/Net/HTTP/Status.gob

A response's status. Every code the IANA registry gives a current name has a constructor, named after its reason phrase as RFC 9110 gives it (ContentTooLarge for 413, UnprocessableContent for 422), so a response is matched by name:

match resp.status {
    OK -> ...
    NotFound -> ...
    _ -> ...
}

One spelling per code. Any other code from 100 to 999 is held by a constructor this module does not export, and fromCode is the only way to make one. fromCode(404) is NotFound, never an anonymous 404, so a match on NotFound sees every 404 there is.

The hidden constructor is Unregistered. A code may be registered later, and gain a constructor; a program that matched it by number through code goes on working, and one that matched _ goes on working too.

type Status = Continue | SwitchingProtocols | Processing | EarlyHints | OK | Created | Accepted | NonAuthoritativeInformation | NoContent | ResetContent | PartialContent | MultiStatus | AlreadyReported | IMUsed | MultipleChoices | MovedPermanently | Found | SeeOther | NotModified | UseProxy | TemporaryRedirect | PermanentRedirect | BadRequest | Unauthorized | PaymentRequired | Forbidden | NotFound | MethodNotAllowed | NotAcceptable | ProxyAuthenticationRequired | RequestTimeout | Conflict | Gone | LengthRequired | PreconditionFailed | ContentTooLarge | URITooLong | UnsupportedMediaType | RangeNotSatisfiable | ExpectationFailed | MisdirectedRequest | UnprocessableContent | Locked | FailedDependency | TooEarly | UpgradeRequired | PreconditionRequired | TooManyRequests | RequestHeaderFieldsTooLarge | UnavailableForLegalReasons | InternalServerError | NotImplemented | BadGateway | ServiceUnavailable | GatewayTimeout | HTTPVersionNotSupported | VariantAlsoNegotiates | InsufficientStorage | LoopDetected | NetworkAuthenticationRequired
fun fromCode : fun(Int) -> Option Net.HTTP.Status.Status

Returns the status with n as its code, if n is from 100 to 999, the range a status line can carry.

fun code : fun(Net.HTTP.Status.Status) -> Int
fun reason : fun(Net.HTTP.Status.Status) -> String

Returns the reason phrase RFC 9110 or the IANA registry gives the code, or "" for a code with none.

fun isInformational : fun(Net.HTTP.Status.Status) -> Bool
fun isSuccess : fun(Net.HTTP.Status.Status) -> Bool
fun isRedirection : fun(Net.HTTP.Status.Status) -> Bool
fun isClientError : fun(Net.HTTP.Status.Status) -> Bool
fun isServerError : fun(Net.HTTP.Status.Status) -> Bool
instance Eq Net.HTTP.Status.Status
instance Show Net.HTTP.Status.Status

Shows the code and reason phrase, 404 Not Found, or the code alone.