package http

  1. Overview
  2. Docs
type t = {
  1. encoding : Transfer.encoding;
    (*
    • deprecated this field will be removed in the future
    *)
  2. headers : Header.t;
    (*

    response HTTP headers

    *)
  3. version : Version.t;
    (*

    (** HTTP version, usually 1.1 *)

    *)
  4. status : Status.t;
    (*

    HTTP status code of the response

    *)
  5. flush : bool;
    (*
    • deprecated this field will be removed in the future. Provide flush in the [respond_*] function instead.
    *)
}
val encoding : t -> Transfer.encoding
val headers : t -> Header.t
val version : t -> Version.t
val status : t -> Status.t
val flush : t -> bool
val compare : t -> t -> int
val is_keep_alive : t -> bool

Return true whether the connection should be reused

val requires_content_length : ?request_meth:Method.t -> t -> bool

requires_content_length ~request_meth t is true if a combination of t and request_meth indicates that a response message must include "Content-Length" header. However, please note exceptions to this:

  • Response with status code of 304 may or may not include the header.
  • Response to request with method HEAD may or may not include the header.

https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2

val content_length : t -> int option

content_length t is Some x if the "Content-Length" header in t exists and its value x is a non negative integer, x>=0

It is None if requires_content_length t = false or the value encoded in "Content-Length" is not a valid integer value, i.e >= 0.

See https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2

val make : ?version:Version.t -> ?status:Status.t -> ?flush:bool -> ?headers:Header.t -> unit -> t

make () is a value of t. The default values for the request, if not specified, are: status is `Ok, version is `HTTP_1_1, flush is false and headers is Header.empty. The request encoding value is determined via the Header.get_transfer_encoding function.

val pp : Format.formatter -> t -> unit
OCaml

Innovation. Community. Security.