package tiny_httpd

  1. Overview
  2. Docs

Output channel (byte sink)

type t = {
  1. output_char : char -> unit;

    Output a single char

  2. output : bytes -> int -> int -> unit;

    Output slice

  3. flush : unit -> unit;

    Flush underlying buffer

  4. close : unit -> unit;

    Close the output. Must be idempotent.


An output channel, ie. a place into which we can write bytes.

This can be a Buffer.t, an out_channel, a Unix.file_descr, etc.

val of_out_channel : ?close_noerr:bool -> out_channel -> t

of_out_channel oc wraps the channel into a Output.t.

  • parameter close_noerr

    if true, then closing the result uses close_out_noerr instead of close_out to close oc

val of_buffer : Buffer.t -> t

of_buffer buf is an output channel that writes directly into buf. flush and close have no effect.

val output_char : t -> char -> unit

Output the buffer slice into this channel

val output : t -> bytes -> int -> int -> unit

Output the buffer slice into this channel

val output_string : t -> string -> unit
val close : t -> unit

Close the channel.

val flush : t -> unit

Flush (ie. force write) any buffered bytes.

val output_buf : t -> Buf.t -> unit
val chunk_encoding : ?buf:Buf.t -> close_rec:bool -> t -> t

chunk_encoding oc makes a new channel that outputs its content into oc in chunk encoding form.

  • parameter close_rec

    if true, closing the result will also close oc

  • parameter buf

    a buffer used to accumulate data into chunks. Chunks are emitted when buf's size gets over a certain threshold, or when flush is called.


Innovation. Community. Security.