tiny_httpd

Minimal HTTP server using good old threads
IN THIS PACKAGE
type t = byte_stream
val close : t -> unit
val empty : t
val of_chan : in_channel -> t

Make a buffered stream from the given channel.

val of_chan_close_noerr : in_channel -> t

Same as of_chan but the close method will never fail.

val of_bytes : ?i:int -> ?len:int -> bytes -> t

A stream that just returns the slice of bytes starting from i and of length len.

val of_string : string -> t
val iter : ( bytes -> int -> int -> unit ) -> t -> unit

Iterate on the chunks of the stream

  • since 0.3
val to_chan : out_channel -> t -> unit

Write the stream to the channel.

  • since 0.3
val with_file : string -> ( t -> 'a ) -> 'a

Open a file with given name, and obtain an input stream on its content. When the function returns, the stream (and file) are closed.

val read_line : ?buf:Buf_.t -> t -> string

Read a line from the stream.

  • parameter buf

    a buffer to (re)use. Its content will be cleared.

val read_all : ?buf:Buf_.t -> t -> string

Read the whole stream into a string.

  • parameter buf

    a buffer to (re)use. Its content will be cleared.