package tiny_httpd
Module Tiny_httpd_streamSource
Byte streams.
These used to live in Tiny_httpd but are now in their own module.
type t = {mutable bs : bytes;(*The bytes
*)mutable off : int;mutable len : int;fill_buf : unit -> unit;(*See the current slice of the internal buffer as
*)bytes, i, len, where the slice isbytes[i] .. [bytes[i+len-1]]. Can block to refill the buffer if there is currently no content. Iflen=0then there is no more data.consume : int -> unit;(*Consume
*)nbytes from the buffer. This should only be called withn <= len.close : unit -> unit;(*Close the stream.
*)_rest : hidden;
}A buffered stream, with a view into the current buffer (or refill if empty), and a function to consume n bytes. See Byte_stream for more details.
Make a buffered stream from the given channel.
Same as of_chan but the close method will never fail.
A stream that just returns the slice of bytes starting from i and of length len.
Write the stream to the channel.
val make :
?bs:bytes ->
?close:(t -> unit) ->
consume:(t -> int -> unit) ->
fill:(t -> unit) ->
unit ->
tmake ~fill () creates a byte stream.
Open a file with given name, and obtain an input stream on its content. When the function returns, the stream (and file) are closed.
Read a line from the stream.
Read the whole stream into a string.
Convert a stream into a stream of byte chunks using the chunked encoding. The size of chunks is not specified.
read_exactly ~size bs returns a new stream that reads exactly size bytes from bs, and then closes.
Write the stream into the channel, using the chunked encoding.