Module Spindle_http.Status

The statuses a handler may answer with.

Every status RFC 9110 §15 defines is a constructor, and so are those of RFC 6585, 7725, 8297 and 8470 -- `Precondition_required, `Too_many_requests, `Request_header_fields_too_large, `Network_authentication_required, `Unavailable_for_legal_reasons, `Early_hints and `Too_early -- so a route reads ~status:`Accepted; `Code n is anything else, WebDAV's among them. A status has one spelling: of_int answers the constructor wherever there is one, and whatever the framework reports or compares has gone through it.

The set is closed at 1.0. A status registered later stays `Code n for every 1.x release, so a match on this type keeps its meaning across them: one written for `Code 418 never stops matching.

type t = [
  1. | `Continue
  2. | `Switching_protocols
  3. | `Early_hints
  4. | `OK
  5. | `Created
  6. | `Accepted
  7. | `Non_authoritative_information
  8. | `No_content
  9. | `Reset_content
  10. | `Partial_content
  11. | `Multiple_choices
  12. | `Moved_permanently
  13. | `Found
  14. | `See_other
  15. | `Not_modified
  16. | `Use_proxy
  17. | `Temporary_redirect
  18. | `Permanent_redirect
  19. | `Bad_request
  20. | `Unauthorized
  21. | `Payment_required
  22. | `Forbidden
  23. | `Not_found
  24. | `Method_not_allowed
  25. | `Not_acceptable
  26. | `Proxy_authentication_required
  27. | `Request_timeout
  28. | `Conflict
  29. | `Gone
  30. | `Length_required
  31. | `Precondition_failed
  32. | `Content_too_large
  33. | `Uri_too_long
  34. | `Unsupported_media_type
  35. | `Range_not_satisfiable
  36. | `Expectation_failed
  37. | `Misdirected_request
  38. | `Unprocessable_content
  39. | `Too_early
  40. | `Upgrade_required
  41. | `Precondition_required
  42. | `Too_many_requests
  43. | `Request_header_fields_too_large
  44. | `Internal_server_error
  45. | `Not_implemented
  46. | `Bad_gateway
  47. | `Service_unavailable
  48. | `Gateway_timeout
  49. | `Http_version_not_supported
  50. | `Network_authentication_required
  51. | `Code of int
]
val to_int : t -> int
val of_int : int -> t

The named constructor for n, or `Code n when there is none: of_int 409 is `Conflict, never `Code 409.

val equal : t -> t -> bool

By number, so `Code 409 and `Conflict are one status.

val reason : t -> string

The phrase a status line carries -- "Not Found" -- and empty for a `Code with no name, which RFC 9112 allows.

val all : t list

Every named status, in numeric order.