package cohttp-mirage

  1. Overview
  2. Docs
exception Retry
type t
val create : ?finalise:(t -> unit Net.IO.t) -> ?persistent:bool -> ?ctx:Net.ctx -> Net.endp -> t

create ?finalise ?persistent ?ctx endp connects to endp. The connection handle may be used immediately, although the connection may not yet be established.

  • parameter finalise

    called when the connection is closed, but before still waiting requests are failed.

  • parameter persistent

    if false, a Connection: close header is sent and the connection closed as soon as possible. If true, it is assumed the remote end does support pipelining and multiple requests may be sent even before receiving any reply. By default we wait for the first response to decide whether connection keep-alive and pipelining is suppored. Chunked encoding can only be used when pipelining is supported. Therefore better avoid using chunked encoding on the very first request.

  • parameter ctx

    See Net.ctx

  • parameter endp

    The remote address, port and protocol to connect to.

val connect : ?finalise:(t -> unit Net.IO.t) -> ?persistent:bool -> ?ctx:Net.ctx -> Net.endp -> t Net.IO.t

Same as create, but returns d promise which gets fulfilled when the connection is established or rejected when connecting fails.

val shutdown : t -> unit

Send EOF. On TCP connections send a FIN packet. On TLS connections send a close notify. No new requests can be sent afterwards, but responses may still be received.

val close : t -> unit

Immediately close connection. All outstanding requests will fail, but non-idempotent requests that already went out on the wire may have produced side-effects.

val is_closed : t -> bool

If is_closed connection is false the connection still accepts new requests.

val length : t -> int

Number of unfulfilled requests. This includes requests already sent out and requests still waitung to be sent.

val notify : t -> unit Net.IO.t

Request notification on change of length and on closing.

val call : t -> Cohttp_lwt.S.call

Queue a request. Please see requester.

OCaml

Innovation. Community. Security.