StatusHTTP status codes per RFC 9110 Section 15
This module provides types and functions for working with HTTP response status codes. Status codes are three-digit integers that indicate the result of an HTTP request.
val src : Logs.Src.tLog source for status code operations
type informational = [ | `Continue100 - Client should continue with request
*)| `Switching_protocols101 - Server is switching protocols
*)| `Processing102 - Server has received and is processing the request
*)| `Early_hints103 - Used to return some response headers before final HTTP message
*) ]1xx Informational responses
type success = [ | `OK200 - Standard response for successful HTTP requests
*)| `Created201 - Request has been fulfilled; new resource created
*)| `Accepted202 - Request accepted, processing pending
*)| `No_content204 - Request processed, no content returned
*)| `Reset_content205 - Request processed, no content returned, reset document view
*)| `Partial_content206 - Partial resource return due to request header
*)| `Multi_status207 - XML, can contain multiple separate responses
*)| `Already_reported208 - Results previously returned
*)| `Im_used226 - Request fulfilled, response is instance-manipulations
*) ]2xx Success responses
type redirection = [ | `Multiple_choices300 - Multiple options for the resource delivered
*)| `Moved_permanently301 - This and all future requests directed to the given URI
*)| `Found302 - Temporary response to request found via alternative URI
*)| `See_other303 - Response to request found via alternative URI
*)| `Not_modified304 - Resource has not been modified since last requested
*)| `Use_proxy305 - Content located elsewhere, retrieve from there (deprecated)
*)| `Temporary_redirect307 - Connect again to different URI as provided
*)| `Permanent_redirect308 - Connect again to a different URI using the same method
*) ]3xx Redirection messages
type client_error = [ | `Bad_request400 - Request cannot be fulfilled due to bad syntax
*)| `Payment_required402 - Payment required, reserved for future use
*)| `Forbidden403 - Server refuses to respond to request
*)| `Not_found404 - Requested resource could not be found
*)| `Method_not_allowed405 - Request method not supported by that resource
*)| `Not_acceptable406 - Content not acceptable according to the Accept headers
*)| `Proxy_authentication_required407 - Client must first authenticate itself with the proxy
*)| `Request_timeout408 - Server timed out waiting for the request
*)| `Conflict409 - Request could not be processed because of conflict
*)| `Gone410 - Resource is no longer available and will not be available again
*)| `Length_required411 - Request did not specify the length of its content
*)| `Precondition_failed412 - Server does not meet request preconditions
*)| `Payload_too_large413 - Request is larger than the server is willing or able to process
*)| `Uri_too_long414 - URI provided was too long for the server to process
*)| `Unsupported_media_type415 - Server does not support media type
*)| `Range_not_satisfiable416 - Client has asked for unprovidable portion of the file
*)| `Expectation_failed417 - Server cannot meet requirements of Expect request-header field
*)| `I_m_a_teapot418 - I'm a teapot (RFC 2324)
*)| `Misdirected_request421 - Request was directed at a server that is not able to produce a response
*)| `Unprocessable_entity422 - Request unable to be followed due to semantic errors
*)| `Locked423 - Resource that is being accessed is locked
*)| `Failed_dependency424 - Request failed due to failure of a previous request
*)| `Too_early425 - Server is unwilling to risk processing a request that might be replayed
*)| `Upgrade_required426 - Client should switch to a different protocol
*)| `Precondition_required428 - Origin server requires the request to be conditional
*)| `Too_many_requests429 - User has sent too many requests in a given amount of time
*)| `Request_header_fields_too_large431 - Server is unwilling to process the request
*) ]4xx Client error responses
type server_error = [ | `Internal_server_error500 - Generic error message
*)| `Not_implemented501 - Server does not recognise method or lacks ability to fulfill
*)| `Bad_gateway502 - Server received an invalid response from upstream server
*)| `Gateway_timeout504 - Gateway did not receive response from upstream server
*)| `Http_version_not_supported505 - Server does not support the HTTP protocol version
*)| `Variant_also_negotiates506 - Content negotiation for the request results in a circular reference
*)| `Insufficient_storage507 - Server is unable to store the representation
*)| `Loop_detected508 - Server detected an infinite loop while processing the request
*)| `Not_extended510 - Further extensions to the request are required
*)| `Network_authentication_required511 - Client needs to authenticate to gain network access
*) ]5xx Server error responses
All standard HTTP status codes
HTTP status type
val to_int : t -> intConvert status to its integer code
val of_int : int -> tConvert an integer to a status
val to_string : t -> stringGet the string representation of a status code (e.g., "200", "404")
val reason_phrase : t -> stringGet the standard reason phrase for a status code (e.g., "OK", "Not Found")
val is_informational : t -> boolCheck if status code is informational (1xx)
val is_success : t -> boolCheck if status code indicates success (2xx)
val is_redirection : t -> boolCheck if status code indicates redirection (3xx)
val is_client_error : t -> boolCheck if status code indicates client error (4xx)
val is_server_error : t -> boolCheck if status code indicates server error (5xx)
val is_error : t -> boolCheck if status code indicates any error (4xx or 5xx)
val is_retryable : t -> boolCheck if a status code suggests the request could be retried. Returns true for:
val should_retry_on_different_host : t -> boolCheck if a status code suggests retrying on a different host might help. Returns true for:
val pp : Format.formatter -> t -> unitPretty printer for status codes
val pp_hum : Format.formatter -> t -> unitHuman-readable pretty printer that includes both code and reason phrase