diff --git a/src/Tiny_httpd.ml b/src/Tiny_httpd.ml index f20d91ee..3ff6347a 100644 --- a/src/Tiny_httpd.ml +++ b/src/Tiny_httpd.ml @@ -1,9 +1,14 @@ +type input_stream = (bytes -> int -> int -> int) * (unit -> unit) +(** An input stream is a function to read bytes into a buffer, + and a function to close *) -(** An input stream. *) -type input_stream = { - ic: in_channel; - mutable buf: bytes; -} +type output_stream = (bytes -> int -> int -> unit) * (unit -> unit) * (unit -> unit) +(** An output stream is a function to output bytes, a function to [flush], + and a function to close. *) + +module Input_stream = struct + +end exception Bad_req of int * string let bad_reqf c fmt = Printf.ksprintf (fun s ->raise (Bad_req (c,s))) fmt diff --git a/src/Tiny_httpd.mli b/src/Tiny_httpd.mli index 1a00f5b0..ab94e536 100644 --- a/src/Tiny_httpd.mli +++ b/src/Tiny_httpd.mli @@ -1,3 +1,24 @@ +type input_stream = (bytes -> int -> int -> int) * (unit -> unit) +(** An input stream is a function to read bytes into a buffer, + and a function to close *) + +type output_stream = (bytes -> int -> int -> unit) * (unit -> unit) * (unit -> unit) +(** An output stream is a function to output bytes, a function to [flush], + and a function to close. *) + +module Input_stream : sig + type t = input_stream + + val of_chan : in_channel -> t + val of_string : string -> t + val of_bytes : bytes -> t +end + +module Output_stream : sig + type t = output_stream + + val of_chan : out_channel -> t +end module Meth : sig type t = [