package httpun

  1. Overview
  2. Docs

Module Httpun.Client_connectionSource

Sourcetype t
Sourcetype error = [
  1. | `Malformed_response of string
  2. | `Invalid_response_body_length of Response.t
  3. | `Exn of exn
]
Sourcetype response_handler = Response.t -> Body.Reader.t -> unit
Sourcetype error_handler = error -> unit
Sourceval create : ?config:Config.t -> unit -> t
Sourceval request : t -> ?flush_headers_immediately:bool -> Request.t -> error_handler:error_handler -> response_handler:response_handler -> Body.Writer.t
Sourceval next_read_operation : t -> [ `Read | `Yield | `Close ]

next_read_operation t returns a value describing the next operation that the caller should conduct on behalf of the connection.

Sourceval read : t -> Bigstringaf.t -> off:int -> len:int -> int

read t bigstring ~off ~len reads bytes of input from the provided range of bigstring and returns the number of bytes consumed by the connection. read should be called after next_read_operation returns a `Read value and additional input is available for the connection to consume.

Sourceval read_eof : t -> Bigstringaf.t -> off:int -> len:int -> int

read_eof t bigstring ~off ~len reads bytes of input from the provided range of bigstring and returns the number of bytes consumed by the connection. read_eof should be called after next_read_operation returns a `Read and an EOF has been received from the communication channel. The connection will attempt to consume any buffered input and then shutdown the HTTP parser for the connection.

Sourceval next_write_operation : t -> [ `Write of Bigstringaf.t IOVec.t list | `Yield | `Close of int ]

next_write_operation t returns a value describing the next operation that the caller should conduct on behalf of the connection.

Sourceval report_write_result : t -> [ `Ok of int | `Closed ] -> unit

report_write_result t result reports the result of the latest write attempt to the connection. report_write_result should be called after a call to next_write_operation that returns a `Write buffer value.

  • `Ok n indicates that the caller successfully wrote n bytes of output from the buffer that the caller was provided by next_write_operation.
  • `Closed indicates that the output destination will no longer accept bytes from the write processor.
Sourceval yield_reader : t -> (unit -> unit) -> unit
Sourceval yield_writer : t -> (unit -> unit) -> unit

yield_writer t continue registers with the connection to call continue when writing should resume. yield_writer should be called after next_write_operation returns a `Yield value.

Sourceval report_exn : t -> exn -> unit

report_exn t exn reports that an error exn has been caught and that it has been attributed to t. Calling this function will switch t into an error state. Depending on the state t is transitioning from, it may call its error handler before terminating the connection.

Sourceval is_closed : t -> bool

is_closed t is true if both the read and write processors have been shutdown. When this is the case next_read_operation will return `Close _ and next_write_operation will return `Write _ until all buffered output has been flushed, at which point it will also return `Close.

Sourceval shutdown : t -> unit

shutdown connection closes the underlying input and output channels of the connection, rendering it unusable for any further communication.

OCaml

Innovation. Community. Security.