cohttp

An OCaml library for HTTP clients and servers
Library cohttp
Module Cohttp . Code
type version = [
| `HTTP_1_0
| `HTTP_1_1
| `Other of string
]
val sexp_of_version : version -> Sexplib0.Sexp.t
val version_of_sexp : Sexplib0.Sexp.t -> version
val __version_of_sexp__ : Sexplib0.Sexp.t -> version
type meth = [
| `GET
| `POST
| `HEAD
| `DELETE
| `PATCH
| `PUT
| `OPTIONS
| `TRACE
| `CONNECT
| `Other of string
]
val sexp_of_meth : meth -> Sexplib0.Sexp.t
val meth_of_sexp : Sexplib0.Sexp.t -> meth
val __meth_of_sexp__ : Sexplib0.Sexp.t -> meth
type informational_status = [
| `Continue(*

Client should continue with request

*)
| `Switching_protocols(*

Server is switching protocols

*)
| `Processing(*

Server has received and is processing the request

*)
| `Checkpoint(*

resume aborted PUT or POST requests

*)
]

Informational

val sexp_of_informational_status : informational_status -> Sexplib0.Sexp.t
val informational_status_of_sexp : Sexplib0.Sexp.t -> informational_status
val __informational_status_of_sexp__ : Sexplib0.Sexp.t -> informational_status
type success_status = [
| `OK(*

standard response for successful HTTP requests

*)
| `Created(*

request has been fulfilled; new resource created

*)
| `Accepted(*

request accepted, processing pending

*)
| `Non_authoritative_information(*

request processed, information may be from another source

*)
| `No_content(*

request processed, no content returned

*)
| `Reset_content(*

request processed, no content returned, reset document view

*)
| `Partial_content(*

partial resource return due to request header

*)
| `Multi_status(*

XML, can contain multiple separate responses

*)
| `Already_reported(*

results previously returned

*)
| `Im_used(*

request fulfilled, reponse is instance-manipulations

*)
]

Success

val sexp_of_success_status : success_status -> Sexplib0.Sexp.t
val success_status_of_sexp : Sexplib0.Sexp.t -> success_status
val __success_status_of_sexp__ : Sexplib0.Sexp.t -> success_status
type redirection_status = [
| `Multiple_choices(*

multiple options for the resource delivered

*)
| `Moved_permanently(*

this and all future requests directed to the given URI

*)
| `Found(*

temporary response to request found via alternative URI

*)
| `See_other(*

permanent response to request found via alternative URI

*)
| `Not_modified(*

resource has not been modified since last requested

*)
| `Use_proxy(*

content located elsewhere, retrieve from there

*)
| `Switch_proxy(*

subsequent requests should use the specified proxy

*)
| `Temporary_redirect(*

connect again to different URI as provided

*)
| `Permanent_redirect(*

connect again to a different URI using the same method

*)
]

Redirection

val sexp_of_redirection_status : redirection_status -> Sexplib0.Sexp.t
val redirection_status_of_sexp : Sexplib0.Sexp.t -> redirection_status
val __redirection_status_of_sexp__ : Sexplib0.Sexp.t -> redirection_status
type client_error_status = [
| `Bad_request(*

request cannot be fulfilled due to bad syntax

*)
| `Unauthorized(*

authentication is possible but has failed

*)
| `Payment_required(*

payment required, reserved for future use

*)
| `Forbidden(*

server refuses to respond to request

*)
| `Not_found(*

requested resource could not be found

*)
| `Method_not_allowed(*

request method not supported by that resource

*)
| `Not_acceptable(*

content not acceptable according to the Accept headers

*)
| `Proxy_authentication_required(*

client must first authenticate itself with the proxy

*)
| `Request_timeout(*

server timed out waiting for the request

*)
| `Conflict(*

request could not be processed because of conflict

*)
| `Gone(*

resource is no longer available and will not be available again

*)
| `Length_required(*

request did not specify the length of its content

*)
| `Precondition_failed(*

server does not meet request preconditions

*)
| `Request_entity_too_large(*

request is larger than the server is willing or able to process

*)
| `Request_uri_too_long(*

URI provided was too long for the server to process

*)
| `Unsupported_media_type(*

server does not support media type

*)
| `Requested_range_not_satisfiable(*

client has asked for unprovidable portion of the file

*)
| `Expectation_failed(*

server cannot meet requirements of Expect request-header field

*)
| `I_m_a_teapot(*

I'm a teapot

*)
| `Enhance_your_calm(*

Twitter rate limiting

*)
| `Unprocessable_entity(*

request unable to be followed due to semantic errors

*)
| `Locked(*

resource that is being accessed is locked

*)
| `Failed_dependency(*

request failed due to failure of a previous request

*)
| `Upgrade_required(*

client should switch to a different protocol

*)
| `Precondition_required(*

origin server requires the request to be conditional

*)
| `Too_many_requests(*

user has sent too many requests in a given amount of time

*)
| `Request_header_fields_too_large(*

server is unwilling to process the request

*)
| `No_response(*

server returns no information and closes the connection

*)
| `Retry_with(*

request should be retried after performing action

*)
| `Blocked_by_windows_parental_controls(*

Windows Parental Controls blocking access to webpage

*)
| `Wrong_exchange_server(*

the server cannot reach the client's mailbox

*)
| `Client_closed_request(*

connection closed by client while HTTP server is processing

*)
]

Client_error

val sexp_of_client_error_status : client_error_status -> Sexplib0.Sexp.t
val client_error_status_of_sexp : Sexplib0.Sexp.t -> client_error_status
val __client_error_status_of_sexp__ : Sexplib0.Sexp.t -> client_error_status
type server_error_status = [
| `Internal_server_error(*

generic error message

*)
| `Not_implemented(*

server does not recognise method or lacks ability to fulfill

*)
| `Bad_gateway(*

server received an invalid response from upstream server

*)
| `Service_unavailable(*

server is currently unavailable

*)
| `Gateway_timeout(*

gateway did not receive response from upstream server

*)
| `Http_version_not_supported(*

server does not support the HTTP protocol version

*)
| `Variant_also_negotiates(*

content negotiation for the request results in a circular reference

*)
| `Insufficient_storage(*

server is unable to store the representation

*)
| `Loop_detected(*

server detected an infinite loop while processing the request

*)
| `Bandwidth_limit_exceeded(*

bandwidth limit exceeded

*)
| `Not_extended(*

further extensions to the request are required

*)
| `Network_authentication_required(*

client needs to authenticate to gain network access

*)
| `Network_read_timeout_error(*

network read timeout behind the proxy

*)
| `Network_connect_timeout_error(*

network connect timeout behind the proxy

*)
]

Server_error

val sexp_of_server_error_status : server_error_status -> Sexplib0.Sexp.t
val server_error_status_of_sexp : Sexplib0.Sexp.t -> server_error_status
val __server_error_status_of_sexp__ : Sexplib0.Sexp.t -> server_error_status
val sexp_of_status : status -> Sexplib0.Sexp.t
val status_of_sexp : Sexplib0.Sexp.t -> status
val __status_of_sexp__ : Sexplib0.Sexp.t -> status
type status_code = [
| `Code of int
| status
]
val sexp_of_status_code : status_code -> Sexplib0.Sexp.t
val status_code_of_sexp : Sexplib0.Sexp.t -> status_code
val __status_code_of_sexp__ : Sexplib0.Sexp.t -> status_code
val string_of_version : version -> string

Convert a version to a string.

val version_of_string : string -> version

Convert a string to a version.

val compare_version : version -> version -> int

Comparison function for version values

val string_of_method : meth -> string

Convert a method to a string.

val method_of_string : string -> meth

Convert a string to a method.

val compare_method : meth -> meth -> int

Comparison function for method values

val status_of_code : int -> status_code

Generate status values from int codes.

val code_of_status : status_code -> int

Generate an int code from a status value.

val string_of_status : status_code -> string

Give a description of the given status value.

val reason_phrase_of_code : int -> string

Give a description of the given int code.

val is_informational : int -> bool

Is the given int code belong to the class of "informational" return code ?

val is_success : int -> bool

Is the given int code belong to the class of "success" return code ?

val is_redirection : int -> bool

Is the given int code belong to the class of "redirection" return code ?

val is_client_error : int -> bool

Is the given int code belong to the class of "client_error" return code ?

val is_server_error : int -> bool

Is the given int code belong to the class of "server_error" return code ?

val is_error : int -> bool

Return true for client and server error status codes.