package cohttp-lwt-unix

  1. Overview
  2. Docs

Module Server.IOSource

include Cohttp_lwt.S.IO with type ic = Lwt_io.input_channel and type oc = Lwt_io.output_channel and type conn = Conduit_lwt_unix.flow and type error = exn
include Cohttp.S.IO with type 'a t = 'a Lwt.t with type ic = Lwt_io.input_channel with type oc = Lwt_io.output_channel with type conn = Conduit_lwt_unix.flow
Sourcetype 'a t = 'a Lwt.t

'a t represents a blocking monad state

Sourceval (>>=) : 'a t -> ('a -> 'b t) -> 'b t

a >>= b will pass the result of a to the b function. This is a monadic bind.

Sourceval return : 'a -> 'a t

return a will construct a constant IO value.

ic represents an input channel

oc represents an output channel

conn represents the underlying network flow

Sourceval read_line : ic -> string option t

read_line ic will read a single line terminated by CR or CRLF from the input channel ic. It returns None if EOF or other error condition is reached.

Sourceval read : ic -> int -> string t

read ic len will block until a maximum of len characters are read from the input channel ic. It returns an empty string if EOF or some other error condition occurs on the input channel, and can also return fewer than len characters if input buffering is not sufficient to satisfy the request.

Sourceval write : oc -> string -> unit t

write oc s will block until the complete s string is written to the output channel oc.

Sourceval flush : oc -> unit t

flush oc will return when all previously buffered content from calling write have been written to the output channel oc.

Sourcetype error = exn
Sourceval catch : (unit -> 'a t) -> ('a, error) result t

catch f is f () >|= Result.ok, unless f fails with an IO error, in which case it returns the error.

Sourceval pp_error : Format.formatter -> error -> unit
OCaml

Innovation. Community. Security.