package dream-httpaf

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Response Status Codes

The status-code element is a three-digit integer code giving the result of the attempt to understand and satisfy the request.

See RFC7231§6 for more details.

type informational = [
  1. | `Continue
  2. | `Switching_protocols
]

The 1xx (Informational) class of status code indicates an interim response for communicating connection status or request progress prior to completing the requested action and sending a final response.

See RFC7231§6.2 for more details.

type successful = [
  1. | `OK
  2. | `Created
  3. | `Accepted
  4. | `Non_authoritative_information
  5. | `No_content
  6. | `Reset_content
  7. | `Partial_content
]

The 2xx (Successful) class of status code indicates that the client's request was successfully received, understood, and accepted.

See RFC7231§6.3 for more details.

type redirection = [
  1. | `Multiple_choices
  2. | `Moved_permanently
  3. | `Found
  4. | `See_other
  5. | `Not_modified
  6. | `Use_proxy
  7. | `Temporary_redirect
]

The 3xx (Redirection) class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.

See RFC7231§6.4 for more details.

type client_error = [
  1. | `Bad_request
  2. | `Unauthorized
  3. | `Payment_required
  4. | `Forbidden
  5. | `Not_found
  6. | `Method_not_allowed
  7. | `Not_acceptable
  8. | `Proxy_authentication_required
  9. | `Request_timeout
  10. | `Conflict
  11. | `Gone
  12. | `Length_required
  13. | `Precondition_failed
  14. | `Payload_too_large
  15. | `Uri_too_long
  16. | `Unsupported_media_type
  17. | `Range_not_satisfiable
  18. | `Expectation_failed
  19. | `Upgrade_required
  20. | `I_m_a_teapot
  21. | `Enhance_your_calm
  22. | `Precondition_required
  23. | `Too_many_requests
  24. | `Request_header_fields_too_large
]

The 4xx (Client Error) class of status code indicates that the client seems to have erred.

See RFC7231§6.5 for more details.

type server_error = [
  1. | `Internal_server_error
  2. | `Not_implemented
  3. | `Bad_gateway
  4. | `Service_unavailable
  5. | `Gateway_timeout
  6. | `Http_version_not_supported
  7. | `Network_authentication_required
]

The 5xx (Server Error) class of status code indicates that the server is aware that it has erred or is incapable of performing the requested method.

See RFC7231§6.6 for more details.

The status codes defined in the HTTP 1.1 RFCs

type t = [
  1. | standard
  2. | `Code of int
]

The standard codes along with support for custom codes.

val default_reason_phrase : standard -> string

default_reason_phrase standard is the example reason phrase provided by RFC7231 for the standard status code. The RFC allows servers to use reason phrases besides these in responses.

val to_code : t -> int

to_code t is the integer representation of t.

val of_code : int -> t

of_code i is the t representation of i. of_code raises Failure if i is not a positive three-digit number.

val unsafe_of_code : int -> t

unsafe_of_code i is equivalent to of_code i, except it accepts any positive code, regardless of the number of digits it has. On negative codes, it will still raise Failure.

val is_informational : t -> bool

is_informational t is true iff t belongs to the Informational class of status codes.

val is_successful : t -> bool

is_successful t is true iff t belongs to the Successful class of status codes.

val is_redirection : t -> bool

is_redirection t is true iff t belongs to the Redirection class of status codes.

val is_client_error : t -> bool

is_client_error t is true iff t belongs to the Client Error class of status codes.

val is_server_error : t -> bool

is_server_error t is true iff t belongs to the Server Error class of status codes.

val is_error : t -> bool

is_error t is true iff t belongs to the Client Error or Server Error class of status codes.

val to_string : t -> string
val of_string : string -> t
val pp_hum : Stdlib.Format.formatter -> t -> unit
OCaml

Innovation. Community. Security.