Module Webs.Http

HTTP nuts and bolts.

Only types, values and codecs.

References.

Encodings

module Base64 : sig ... end

Base64 codec.

module Pct : sig ... end

Percent-encoding codec.

Names

In HTTP it is often required 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.

Cookies.

Paths

type path = string list

The type for absolute URI paths. This is a percent decoded list of path segments. Path segments can be empty (""). The empty list denotes absence of path. The root path "/" is represented by the list [""] while "/a" is represented by ["a"].

WARNING. You should never concatenate these segments with a separator to get a filepath, the segments are not guaranteed not to contain directory separators. Use the function Path.to_undotted_filepath.

module Path : sig ... end

Paths.

queries

module Query : sig ... end

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

Status codes

type status = int

The type for HTTP status codes.

module Status : sig ... end

Statuses.

Informational 1xx

val s100_continue : status

100

val s101_switching_protocols : status

101

Sucessful 2xx

val s200_ok : status

200

val s201_created : status

201

val s202_accepted : status

202

val s203_non_authoritative_information : status

203

val s204_no_content : status

204

val s205_reset_content : status

205

val s206_partial_content : status

206

Redirection 3xx

val s300_multiple_choices : status

300

val s301_moved_permanently : status

301

val s302_found : status

302

val s303_see_other : status

303

val s304_not_modified : status

304

val s305_use_proxy : status

305

val s307_temporary_redirect : status

307

Client Error 4xx

val s400_bad_request : status

400

val s401_unauthorized : status

401

val s402_payement_required : status

402

val s403_forbidden : status

403

val s404_not_found : status

404

val s405_not_allowed : status

405

val s406_not_acceptable : status

406

val s407_proxy_authentication_required : status

407

val s408_request_time_out : status

408

val s409_conflict : status

409

val s410_gone : status

410

val s411_length_required : status

411

val s412_precondition_failed : status

412

val s413_payload_too_large : status

413

val s414_uri_too_long : status

414

val s415_unsupported_media_type : status

415

val s416_range_not_satisfiable : status

416

val s417_expectation_failed : status

417

val s418_i'm_a_teapot : status

418

val s426_upgrade_required : status

436

Server Error 5xx

val s500_server_error : status

500

val s501_not_implemented : status

501

val s502_bad_gateway : status

502

val s503_service_unavailable : status

503

val s504_gateway_time_out : status

504

val s505_http_version_not_supported : status

505

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

module Private : sig ... end