Module Webs.Http

HTTP nuts and bolts.

Just types, values, codecs and logic fragments.

References.

Encodings

module Base64 : sig ... end

Base64 codec.

module Pct : sig ... end

Percent-encoding codec.

Names

HTTP often requires to perform US-ASCII case insensitive comparisons on HTTP tokens. Values of type name represent US-ASCII lowercased HTTP tokens.

type name = private string

The type for lowercased HTTP tokens. In particular header field-names.

module Name : sig ... end

Names.

MIME types

type mime_type = string

The type for MIME types.

module Mime_type : sig ... end

A few ubiquitous MIME types.

Methods

type meth = [
| `GET

GET

| `HEAD

HEAD

| `POST

POST

| `PUT

PUT

| `DELETE

DELETE

| `CONNECT

CONNECT

| `OPTIONS

OPTIONS

| `TRACE

TRACE

| `PATCH

PATCH '

| `Other of string

other token

]

The type for HTTP request methods.

module Meth : sig ... end

HTTP request methods

type headers

The type for HTTP headers. Maps header names to string values such that for:

  • Single valued headers, the value is the string.
  • Multi-valued headers, the values are comma ',' separated as per specification. Use H.values_of_string on the string.
  • H.set_cookie header, must be treated specially since it can be repeated but does not follow the syntax of multi-valued headers. The values are stored in the string separated by '\x00' values, use H.set_cookie and H.values_of_set_cookie_value to handle the field. On H.encode this results in separate set-cookie headers.
module H : sig ... end

HTTP headers and values.

Paths

type path = string list

The type for absolute URI paths represented as non-empty lists of percent-decoded path segments. The empty list denotes the absence of a path.

Path segments can be empty "". The root path / is represented by the list [""] and /a by ["a"], see more examples here.

WARNING. You should never concatenate these segments with a separator to get a file path because they may contain stray percent-decoded directory separators. Use the function Path.to_undotted_filepath to interpret paths as file paths.

module Path : sig ... end

Paths.

queries

module Query : sig ... end

URI query and application/x-www-form-urlencoded codec.

Etags

module Etag : sig ... end

Entity tags.

Cookies.

Status codes

type status = int

The type for HTTP status codes.

module Status : sig ... end

Statuses.

Informational 1xx

val s100_continue : status
val s101_switching_protocols : status

Sucessful 2xx

val s200_ok : status
val s201_created : status
val s202_accepted : status
val s203_non_authoritative_information : status
val s204_no_content : status
val s205_reset_content : status
val s206_partial_content : status

Redirection 3xx

val s300_multiple_choices : status
val s301_moved_permanently : status
val s302_found : status
val s303_see_other : status
val s304_not_modified : status
val s305_use_proxy : status
val s307_temporary_redirect : status

Client Error 4xx

val s400_bad_request : status
val s401_unauthorized : status
val s402_payement_required : status
val s403_forbidden : status
val s404_not_found : status
val s405_not_allowed : status
val s406_not_acceptable : status
val s407_proxy_authentication_required : status
val s408_request_time_out : status
val s409_conflict : status
val s410_gone : status
val s411_length_required : status
val s412_precondition_failed : status
val s413_payload_too_large : status
val s414_uri_too_long : status
val s415_unsupported_media_type : status
val s416_range_not_satisfiable : status
val s417_expectation_failed : status
val s418_i'm_a_teapot : status
val s426_upgrade_required : status

Server Error 5xx

val s500_server_error : status
val s501_not_implemented : status
val s502_bad_gateway : status
val s503_service_unavailable : status
val s504_gateway_time_out : status
val s505_http_version_not_supported : status

Versions

type version = int * int

The type for HTTP versions. Both integers must be in the interval [0;9].

module Version : sig ... end

HTTP versions.

Low-level codecs

Low-level codecs

Warning. This API is unstable and subject to change between minor versions of the library.

module Private : sig ... end