package http
Library
Module
Module type
Parameter
Class
Class type
type t = {
headers : Header.t;
(*HTTP request headers
*)meth : Method.t;
(*HTTP request method
*)scheme : string option;
(*URI scheme (http or https)
*)resource : string;
(*Request path and query
*)version : Version.t;
(*HTTP version, usually 1.1
*)encoding : Transfer.encoding;
(**)
}
val has_body : t -> [ `No | `Unknown | `Yes ]
val scheme : t -> string option
val resource : t -> string
val encoding : t -> Transfer.encoding
val is_keep_alive : t -> bool
Return true whether the connection should be reused
val requires_content_length : t -> bool
requires_content_length t
is true
if t.meth
is one of `POST, `PUT or `PATCH
. Otherwise it is false
.
A true
value indicates that a request must include a "Content-Length" header.
See 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 supports_chunked_trailers : t -> bool
supports_chunked_trailers t
is true
if t
contains HTTP header "TE: trailers". Otherwise it is false
.
add_te_trailers t
adds HTTP headers, 'TE' and 'Connection' to indicate that a user-agent can handle HTTP chunked trailers headers.
val make :
?meth:Method.t ->
?version:Version.t ->
?headers:Header.t ->
?scheme:string ->
string ->
t
make resource
is a value of t
. The default values for the response, if not specified, are as follows: meth
is `GET
, version
is `HTTP_1_1
, headers
is Header.empty
and scheme
is None
. The request encoding value is determined via the Header.get_transfer_encoding
function.
val pp : Format.formatter -> t -> unit