diff --git a/dev/tiny_httpd/Tiny_httpd/index.html b/dev/tiny_httpd/Tiny_httpd/index.html index b75295d4..867da8e8 100644 --- a/dev/tiny_httpd/Tiny_httpd/index.html +++ b/dev/tiny_httpd/Tiny_httpd/index.html @@ -1,5 +1,5 @@ -
Tiny_httpdTiny Http Server
This library implements a very simple, basic HTTP/1.1 server using blocking IOs and threads. Basic routing based on Scanf is provided for convenience, so that several handlers can be registered.
It is possible to use a thread pool, see create's argument new_thread.
The echo example (see src/examples/echo.ml) demonstrates some of the features by declaring a few endpoints, including one for uploading files:
module S = Tiny_httpd
+Tiny_httpd (tiny_httpd.Tiny_httpd) Module Tiny_httpd
Tiny Http Server
This library implements a very simple, basic HTTP/1.1 server using blocking IOs and threads. Basic routing based on Scanf is provided for convenience, so that several handlers can be registered.
It is possible to use a thread pool, see create's argument new_thread.
The echo example (see src/examples/echo.ml) demonstrates some of the features by declaring a few endpoints, including one for uploading files:
module S = Tiny_httpd
let () =
let server = S.create () in
diff --git a/dev/tiny_httpd/Tiny_httpd_atomic_/index.html b/dev/tiny_httpd/Tiny_httpd_atomic_/index.html
index 63f6c2dd..3187d9b4 100644
--- a/dev/tiny_httpd/Tiny_httpd_atomic_/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_atomic_/index.html
@@ -1,2 +1,2 @@
-Tiny_httpd_atomic_ (tiny_httpd.Tiny_httpd_atomic_) Module Tiny_httpd_atomic_
\ No newline at end of file
+Tiny_httpd_atomic_ (tiny_httpd.Tiny_httpd_atomic_) Module Tiny_httpd_atomic_
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_buf/index.html b/dev/tiny_httpd/Tiny_httpd_buf/index.html
index 3f18c8a9..85abc1d2 100644
--- a/dev/tiny_httpd/Tiny_httpd_buf/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_buf/index.html
@@ -1,2 +1,2 @@
-Tiny_httpd_buf (tiny_httpd.Tiny_httpd_buf) Module Tiny_httpd_buf
Simple buffer.
These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.
val size : t -> intval clear : t -> unitval create : ?size:int -> unit -> tval contents : t -> stringval bytes_slice : t -> bytesAccess underlying slice of bytes.
val contents_and_clear : t -> stringGet contents of the buffer and clear it.
val add_char : t -> char -> unitAdd a single char.
val add_bytes : t -> bytes -> int -> int -> unitAppend given bytes slice to the buffer.
val add_string : t -> string -> unitAdd string.
val add_buffer : t -> Stdlib.Buffer.t -> unitAppend bytes from buffer.
\ No newline at end of file
+Tiny_httpd_buf (tiny_httpd.Tiny_httpd_buf) Module Tiny_httpd_buf
Simple buffer.
These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.
val size : t -> intval clear : t -> unitval create : ?size:int -> unit -> tval contents : t -> stringval bytes_slice : t -> bytesAccess underlying slice of bytes.
val contents_and_clear : t -> stringGet contents of the buffer and clear it.
val add_char : t -> char -> unitAdd a single char.
val add_bytes : t -> bytes -> int -> int -> unitAppend given bytes slice to the buffer.
val add_string : t -> string -> unitAdd string.
val add_buffer : t -> Stdlib.Buffer.t -> unitAppend bytes from buffer.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html b/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html
index ae5c3e84..f62ccfb8 100644
--- a/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html
@@ -1,2 +1,2 @@
-Embedded_fs (tiny_httpd.Tiny_httpd_dir.Embedded_fs) Module Tiny_httpd_dir.Embedded_fs
An embedded file system, as a list of files with (relative) paths. This is useful in combination with the "tiny-httpd-mkfs" tool, which embeds the files it's given into a OCaml module.
val create : ?mtime:float -> unit -> tval add_file : ?mtime:float -> t -> path:string -> string -> unitAdd file to the virtual file system.
\ No newline at end of file
+Embedded_fs (tiny_httpd.Tiny_httpd_dir.Embedded_fs) Module Tiny_httpd_dir.Embedded_fs
An embedded file system, as a list of files with (relative) paths. This is useful in combination with the "tiny-httpd-mkfs" tool, which embeds the files it's given into a OCaml module.
val create : ?mtime:float -> unit -> tval add_file : ?mtime:float -> t -> path:string -> string -> unitAdd file to the virtual file system.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_dir/index.html b/dev/tiny_httpd/Tiny_httpd_dir/index.html
index f6310bf2..4cac65ee 100644
--- a/dev/tiny_httpd/Tiny_httpd_dir/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_dir/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_dir (tiny_httpd.Tiny_httpd_dir) Module Tiny_httpd_dir
Serving static content from directories
This module provides the same functionality as the "http_of_dir" tool. It exposes a directory (and its subdirectories), with the optional ability to delete or upload files.
type dir_behavior = | Index(*Redirect to index.html if present, else fails.
*)| Lists(*Lists content of directory. Be careful of security implications.
*)| Index_or_lists(*Redirect to index.html if present and lists content otherwise. This is useful for tilde ("~") directories and other per-user behavior, but be mindful of security implications
*)| Forbidden(*Forbid access to directory. This is suited for serving assets, for example.
*)
behavior of static directory.
This controls what happens when the user requests the path to a directory rather than a file.
Type used to prevent users from building a config directly. Use default_config or config instead.
type config = {mutable download : bool;(*Is downloading files allowed?
*)mutable dir_behavior : dir_behavior;(*Behavior when serving a directory and not a file
*)mutable delete : bool;(*Is deleting a file allowed? (with method DELETE)
*)mutable upload : bool;(*Is uploading a file allowed? (with method PUT)
*)mutable max_upload_size : int;_rest : hidden;(*Just ignore this field.
*)
}configuration for static file handlers. This might get more fields over time.
val default_config : unit -> configdefault configuration:
+Tiny_httpd_dir (tiny_httpd.Tiny_httpd_dir) Module Tiny_httpd_dir
Serving static content from directories
This module provides the same functionality as the "http_of_dir" tool. It exposes a directory (and its subdirectories), with the optional ability to delete or upload files.
type dir_behavior = | Index(*Redirect to index.html if present, else fails.
*)| Lists(*Lists content of directory. Be careful of security implications.
*)| Index_or_lists(*Redirect to index.html if present and lists content otherwise. This is useful for tilde ("~") directories and other per-user behavior, but be mindful of security implications
*)| Forbidden(*Forbid access to directory. This is suited for serving assets, for example.
*)
behavior of static directory.
This controls what happens when the user requests the path to a directory rather than a file.
Type used to prevent users from building a config directly. Use default_config or config instead.
type config = {mutable download : bool;(*Is downloading files allowed?
*)mutable dir_behavior : dir_behavior;(*Behavior when serving a directory and not a file
*)mutable delete : bool;(*Is deleting a file allowed? (with method DELETE)
*)mutable upload : bool;(*Is uploading a file allowed? (with method PUT)
*)mutable max_upload_size : int;_rest : hidden;(*Just ignore this field.
*)
}configuration for static file handlers. This might get more fields over time.
val default_config : unit -> configdefault configuration:
{ download=true
; dir_behavior=Forbidden
; delete=false
diff --git a/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html b/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html
index 21235004..0d0d410b 100644
--- a/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html
@@ -1,2 +1,2 @@
-VFS (tiny_httpd.Tiny_httpd_dir.VFS) Module type Tiny_httpd_dir.VFS
Virtual file system.
This is used to emulate a file system from pure OCaml functions and data, e.g. for resources bundled inside the web server.
file_exists vfs path returns true if path points to a file or directory inside vfs.
List directory. This only returns basenames, the files need to be put in the directory path using Filename.concat.
Create a file and obtain a pair write, close
val read_file_content : string -> Tiny_httpd_stream.tRead content of a file
\ No newline at end of file
+VFS (tiny_httpd.Tiny_httpd_dir.VFS) Module type Tiny_httpd_dir.VFS
Virtual file system.
This is used to emulate a file system from pure OCaml functions and data, e.g. for resources bundled inside the web server.
file_exists vfs path returns true if path points to a file or directory inside vfs.
List directory. This only returns basenames, the files need to be put in the directory path using Filename.concat.
Create a file and obtain a pair write, close
val read_file_content : string -> Tiny_httpd_stream.tRead content of a file
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_html/index.html b/dev/tiny_httpd/Tiny_httpd_html/index.html
index d7250740..ffeaff66 100644
--- a/dev/tiny_httpd/Tiny_httpd_html/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_html/index.html
@@ -1,4 +1,4 @@
-Tiny_httpd_html (tiny_httpd.Tiny_httpd_html) Module Tiny_httpd_html
HTML combinators.
This module provides combinators to produce html. It doesn't enforce the well-formedness of the html, unlike Tyxml, but it's simple and should be reasonably efficient.
module IO = Tiny_httpd_iomodule Out = Tiny_httpd_html_.OutOutput for HTML combinators.
type elt = Out.t -> unitA html element. It is represented by its output function, so we can directly print it.
Element with children, represented as a list.
A chunk of sub-elements, possibly empty.
Element with children, represented as a list of sub_elt to be flattened
val sub_empty : sub_eltSub-element with nothing inside. Useful in conditionals, when one decides not to emit a sub-element at all.
val txt : string -> eltEmit a string value, which will be escaped.
val txtf :
+Tiny_httpd_html (tiny_httpd.Tiny_httpd_html) Module Tiny_httpd_html
HTML combinators.
This module provides combinators to produce html. It doesn't enforce the well-formedness of the html, unlike Tyxml, but it's simple and should be reasonably efficient.
module IO = Tiny_httpd_iomodule Out = Tiny_httpd_html_.OutOutput for HTML combinators.
type elt = Out.t -> unitA html element. It is represented by its output function, so we can directly print it.
Element with children, represented as a list.
A chunk of sub-elements, possibly empty.
Element with children, represented as a list of sub_elt to be flattened
val sub_empty : sub_eltSub-element with nothing inside. Useful in conditionals, when one decides not to emit a sub-element at all.
val txt : string -> eltEmit a string value, which will be escaped.
val txtf :
('a, Stdlib.Format.formatter, unit, Out.t -> unit) Stdlib.format4 ->
'bFormatted version of txt
val raw_html : string -> eltEmit raw HTML. Caution, this can lead to injection vulnerabilities, never use with text that comes from untrusted users.
tag "menuitem", see mdn
tag "footer", see mdn
tag "footer", see mdn
tag "menu", see mdn
tag "menu", see mdn
tag "nav", see mdn
tag "nav", see mdn
module A = Tiny_httpd_html_.AAttributes.
val to_out_channel : ?top:bool -> elt -> IO.Out_channel.t -> unitWrite an HTML element to this out channel.
val to_string : ?top:bool -> elt -> stringConvert a HTML element to a string.
val to_string_l : elt list -> stringConvert a list of HTML elements to a string. This is designed for fragments of HTML that are to be injected inside a bigger context, as it's invalid to have multiple elements at the toplevel of a HTML document.
val to_string_top : elt -> stringval to_out_channel_top : elt -> IO.Out_channel.t -> unitWrite a toplevel element to an output channel.
val to_writer : ?top:bool -> elt -> IO.Writer.tProduce a streaming writer from this HTML element.
val to_stream : elt -> Tiny_httpd_stream.tConvert a HTML element to a stream. This might just convert it to a string first, do not assume it to be more efficient.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_html_/A/index.html b/dev/tiny_httpd/Tiny_httpd_html_/A/index.html
index 48a2a04e..76232721 100644
--- a/dev/tiny_httpd/Tiny_httpd_html_/A/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_html_/A/index.html
@@ -1,2 +1,2 @@
-A (tiny_httpd.Tiny_httpd_html_.A) Module Tiny_httpd_html_.A
Attributes.
This module contains combinator for the standard attributes. One can also just use a pair of strings.
type t = string -> attributeAttribute builder
val accept : tAttribute "accept".
val accept_charset : tAttribute "accept-charset".
val accesskey : tAttribute "accesskey".
val action : tAttribute "action".
val align : tAttribute "align".
val allow : tAttribute "allow".
val alt : tAttribute "alt".
val async : tAttribute "async".
val autocapitalize : tAttribute "autocapitalize".
val autocomplete : tAttribute "autocomplete".
val autofocus : tAttribute "autofocus".
val autoplay : tAttribute "autoplay".
val buffered : tAttribute "buffered".
val capture : tAttribute "capture".
val challenge : tAttribute "challenge".
val charset : tAttribute "charset".
val checked : tAttribute "checked".
val cite : tAttribute "cite".
val class_ : tAttribute "class".
val code : tAttribute "code".
val codebase : tAttribute "codebase".
val cols : tAttribute "cols".
val colspan : tAttribute "colspan".
val content : tAttribute "content".
val contenteditable : tAttribute "contenteditable".
Attribute "contextmenu".
val controls : tAttribute "controls".
val coords : tAttribute "coords".
val crossorigin : tAttribute "crossorigin".
val csp : tAttribute "csp".
val data : tAttribute "data".
val data_star : tAttribute "data-*".
val datetime : tAttribute "datetime".
val decoding : tAttribute "decoding".
val default : tAttribute "default".
val defer : tAttribute "defer".
val dir : tAttribute "dir".
val dirname : tAttribute "dirname".
val disabled : tAttribute "disabled".
val download : tAttribute "download".
val draggable : tAttribute "draggable".
val enctype : tAttribute "enctype".
val enterkeyhint : tAttribute "enterkeyhint".
val for_ : tAttribute "for".
val form : tAttribute "form".
val formaction : tAttribute "formaction".
val formenctype : tAttribute "formenctype".
val formmethod : tAttribute "formmethod".
val formnovalidate : tAttribute "formnovalidate".
val formtarget : tAttribute "formtarget".
val headers : tAttribute "headers".
Attribute "hidden".
val high : tAttribute "high".
val href : tAttribute "href".
val hreflang : tAttribute "hreflang".
val http_equiv : tAttribute "http-equiv".
val icon : tAttribute "icon".
val id : tAttribute "id".
val importance : tAttribute "importance".
val integrity : tAttribute "integrity".
val ismap : tAttribute "ismap".
val itemprop : tAttribute "itemprop".
val keytype : tAttribute "keytype".
val kind : tAttribute "kind".
val label : tAttribute "label".
val lang : tAttribute "lang".
val language : tAttribute "language".
val list : tAttribute "list".
val loop : tAttribute "loop".
val low : tAttribute "low".
val manifest : tAttribute "manifest".
val max : tAttribute "max".
val maxlength : tAttribute "maxlength".
val minlength : tAttribute "minlength".
val media : tAttribute "media".
val method_ : tAttribute "method".
val min : tAttribute "min".
val multiple : tAttribute "multiple".
val muted : tAttribute "muted".
val name : tAttribute "name".
val novalidate : tAttribute "novalidate".
val open_ : tAttribute "open".
val optimum : tAttribute "optimum".
val pattern : tAttribute "pattern".
val ping : tAttribute "ping".
val placeholder : tAttribute "placeholder".
val poster : tAttribute "poster".
val preload : tAttribute "preload".
val radiogroup : tAttribute "radiogroup".
val readonly : tAttribute "readonly".
val referrerpolicy : tAttribute "referrerpolicy".
val rel : tAttribute "rel".
val required : tAttribute "required".
val reversed : tAttribute "reversed".
val rows : tAttribute "rows".
val rowspan : tAttribute "rowspan".
val sandbox : tAttribute "sandbox".
val scope : tAttribute "scope".
val scoped : tAttribute "scoped".
val selected : tAttribute "selected".
val shape : tAttribute "shape".
val size : tAttribute "size".
val sizes : tAttribute "sizes".
val slot : tAttribute "slot".
val span : tAttribute "span".
val spellcheck : tAttribute "spellcheck".
val src : tAttribute "src".
val srcdoc : tAttribute "srcdoc".
val srclang : tAttribute "srclang".
val srcset : tAttribute "srcset".
val start : tAttribute "start".
val step : tAttribute "step".
val style : tAttribute "style".
val summary : tAttribute "summary".
val tabindex : tAttribute "tabindex".
val target : tAttribute "target".
val title : tAttribute "title".
val translate : tAttribute "translate".
val text : tAttribute "Text".
val type_ : tAttribute "type".
val usemap : tAttribute "usemap".
val value : tAttribute "value".
val width : tAttribute "width".
val wrap : tAttribute "wrap".
\ No newline at end of file
+A (tiny_httpd.Tiny_httpd_html_.A) Module Tiny_httpd_html_.A
Attributes.
This module contains combinator for the standard attributes. One can also just use a pair of strings.
type t = string -> attributeAttribute builder
val accept : tAttribute "accept".
val accept_charset : tAttribute "accept-charset".
val accesskey : tAttribute "accesskey".
val action : tAttribute "action".
val align : tAttribute "align".
val allow : tAttribute "allow".
val alt : tAttribute "alt".
val async : tAttribute "async".
val autocapitalize : tAttribute "autocapitalize".
val autocomplete : tAttribute "autocomplete".
val autofocus : tAttribute "autofocus".
val autoplay : tAttribute "autoplay".
val buffered : tAttribute "buffered".
val capture : tAttribute "capture".
val challenge : tAttribute "challenge".
val charset : tAttribute "charset".
val checked : tAttribute "checked".
val cite : tAttribute "cite".
val class_ : tAttribute "class".
val code : tAttribute "code".
val codebase : tAttribute "codebase".
val cols : tAttribute "cols".
val colspan : tAttribute "colspan".
val content : tAttribute "content".
val contenteditable : tAttribute "contenteditable".
Attribute "contextmenu".
val controls : tAttribute "controls".
val coords : tAttribute "coords".
val crossorigin : tAttribute "crossorigin".
val csp : tAttribute "csp".
val data : tAttribute "data".
val data_star : tAttribute "data-*".
val datetime : tAttribute "datetime".
val decoding : tAttribute "decoding".
val default : tAttribute "default".
val defer : tAttribute "defer".
val dir : tAttribute "dir".
val dirname : tAttribute "dirname".
val disabled : tAttribute "disabled".
val download : tAttribute "download".
val draggable : tAttribute "draggable".
val enctype : tAttribute "enctype".
val enterkeyhint : tAttribute "enterkeyhint".
val for_ : tAttribute "for".
val form : tAttribute "form".
val formaction : tAttribute "formaction".
val formenctype : tAttribute "formenctype".
val formmethod : tAttribute "formmethod".
val formnovalidate : tAttribute "formnovalidate".
val formtarget : tAttribute "formtarget".
val headers : tAttribute "headers".
Attribute "hidden".
val high : tAttribute "high".
val href : tAttribute "href".
val hreflang : tAttribute "hreflang".
val http_equiv : tAttribute "http-equiv".
val icon : tAttribute "icon".
val id : tAttribute "id".
val importance : tAttribute "importance".
val integrity : tAttribute "integrity".
val ismap : tAttribute "ismap".
val itemprop : tAttribute "itemprop".
val keytype : tAttribute "keytype".
val kind : tAttribute "kind".
val label : tAttribute "label".
val lang : tAttribute "lang".
val language : tAttribute "language".
val list : tAttribute "list".
val loop : tAttribute "loop".
val low : tAttribute "low".
val manifest : tAttribute "manifest".
val max : tAttribute "max".
val maxlength : tAttribute "maxlength".
val minlength : tAttribute "minlength".
val media : tAttribute "media".
val method_ : tAttribute "method".
val min : tAttribute "min".
val multiple : tAttribute "multiple".
val muted : tAttribute "muted".
val name : tAttribute "name".
val novalidate : tAttribute "novalidate".
val open_ : tAttribute "open".
val optimum : tAttribute "optimum".
val pattern : tAttribute "pattern".
val ping : tAttribute "ping".
val placeholder : tAttribute "placeholder".
val poster : tAttribute "poster".
val preload : tAttribute "preload".
val radiogroup : tAttribute "radiogroup".
val readonly : tAttribute "readonly".
val referrerpolicy : tAttribute "referrerpolicy".
val rel : tAttribute "rel".
val required : tAttribute "required".
val reversed : tAttribute "reversed".
val rows : tAttribute "rows".
val rowspan : tAttribute "rowspan".
val sandbox : tAttribute "sandbox".
val scope : tAttribute "scope".
val scoped : tAttribute "scoped".
val selected : tAttribute "selected".
val shape : tAttribute "shape".
val size : tAttribute "size".
val sizes : tAttribute "sizes".
val slot : tAttribute "slot".
val span : tAttribute "span".
val spellcheck : tAttribute "spellcheck".
val src : tAttribute "src".
val srcdoc : tAttribute "srcdoc".
val srclang : tAttribute "srclang".
val srcset : tAttribute "srcset".
val start : tAttribute "start".
val step : tAttribute "step".
val style : tAttribute "style".
val summary : tAttribute "summary".
val tabindex : tAttribute "tabindex".
val target : tAttribute "target".
val title : tAttribute "title".
val translate : tAttribute "translate".
val text : tAttribute "Text".
val type_ : tAttribute "type".
val usemap : tAttribute "usemap".
val value : tAttribute "value".
val width : tAttribute "width".
val wrap : tAttribute "wrap".
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html b/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html
index 2fd0f8d4..b47b1071 100644
--- a/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html
@@ -1,2 +1,2 @@
-Out (tiny_httpd.Tiny_httpd_html_.Out) Module Tiny_httpd_html_.Out
Output for HTML combinators.
This output type is used to produce a string reasonably efficiently from a tree of combinators.
NOTE: this is experimental and an unstable API.
val create_of_buffer : Stdlib.Buffer.t -> tval create_of_out : Tiny_httpd_io.Out_channel.t -> tval flush : t -> unitval add_char : t -> char -> unitval add_string : t -> string -> unitval add_format_nl : t -> unitval with_no_format_nl : t -> (unit -> 'a) -> 'a
\ No newline at end of file
+Out (tiny_httpd.Tiny_httpd_html_.Out) Module Tiny_httpd_html_.Out
Output for HTML combinators.
This output type is used to produce a string reasonably efficiently from a tree of combinators.
NOTE: this is experimental and an unstable API.
val create_of_buffer : Stdlib.Buffer.t -> tval create_of_out : Tiny_httpd_io.Out_channel.t -> tval flush : t -> unitval add_char : t -> char -> unitval add_string : t -> string -> unitval add_format_nl : t -> unitval with_no_format_nl : t -> (unit -> 'a) -> 'a
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_html_/index.html b/dev/tiny_httpd/Tiny_httpd_html_/index.html
index db2adb23..df3357ab 100644
--- a/dev/tiny_httpd/Tiny_httpd_html_/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_html_/index.html
@@ -1,4 +1,4 @@
-Tiny_httpd_html_ (tiny_httpd.Tiny_httpd_html_) Module Tiny_httpd_html_
module Out : sig ... endOutput for HTML combinators.
type elt = Out.t -> unitA html element. It is represented by its output function, so we can directly print it.
Element with children, represented as a list.
A chunk of sub-elements, possibly empty.
Element with children, represented as a list of sub_elt to be flattened
val sub_empty : sub_eltSub-element with nothing inside. Useful in conditionals, when one decides not to emit a sub-element at all.
val txt : string -> eltEmit a string value, which will be escaped.
val txtf :
+Tiny_httpd_html_ (tiny_httpd.Tiny_httpd_html_) Module Tiny_httpd_html_
module Out : sig ... endOutput for HTML combinators.
type elt = Out.t -> unitA html element. It is represented by its output function, so we can directly print it.
Element with children, represented as a list.
A chunk of sub-elements, possibly empty.
Element with children, represented as a list of sub_elt to be flattened
val sub_empty : sub_eltSub-element with nothing inside. Useful in conditionals, when one decides not to emit a sub-element at all.
val txt : string -> eltEmit a string value, which will be escaped.
val txtf :
('a, Stdlib.Format.formatter, unit, Out.t -> unit) Stdlib.format4 ->
'bFormatted version of txt
val raw_html : string -> eltEmit raw HTML. Caution, this can lead to injection vulnerabilities, never use with text that comes from untrusted users.
tag "menuitem", see mdn
tag "footer", see mdn
tag "footer", see mdn
tag "menu", see mdn
tag "menu", see mdn
tag "nav", see mdn
tag "nav", see mdn
module A : sig ... endAttributes.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_io/In_channel/index.html b/dev/tiny_httpd/Tiny_httpd_io/In_channel/index.html
index 550db665..80243abc 100644
--- a/dev/tiny_httpd/Tiny_httpd_io/In_channel/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_io/In_channel/index.html
@@ -1,2 +1,2 @@
-In_channel (tiny_httpd.Tiny_httpd_io.In_channel) Module Tiny_httpd_io.In_channel
Input channel (byte source)
type t = {input : bytes -> int -> int -> int;(*Read into the slice. Returns 0 only if the channel is closed.
*)close : unit -> unit;(*Close the input. Must be idempotent.
*)
}An input channel, i.e an incoming stream of bytes.
This can be a string, an int_channel, an Unix.file_descr, a decompression wrapper around another input channel, etc.
val of_in_channel : ?close_noerr:bool -> Stdlib.in_channel -> tval of_unix_fd : ?close_noerr:bool -> Unix.file_descr -> tval input : t -> bytes -> int -> int -> intRead into the given slice.
val close : t -> unitClose the channel.
\ No newline at end of file
+In_channel (tiny_httpd.Tiny_httpd_io.In_channel) Module Tiny_httpd_io.In_channel
Input channel (byte source)
type t = {input : bytes -> int -> int -> int;(*Read into the slice. Returns 0 only if the channel is closed.
*)close : unit -> unit;(*Close the input. Must be idempotent.
*)
}An input channel, i.e an incoming stream of bytes.
This can be a string, an int_channel, an Unix.file_descr, a decompression wrapper around another input channel, etc.
val of_in_channel : ?close_noerr:bool -> Stdlib.in_channel -> tval of_unix_fd : ?close_noerr:bool -> Unix.file_descr -> tval input : t -> bytes -> int -> int -> intRead into the given slice.
val close : t -> unitClose the channel.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_io/Out_channel/index.html b/dev/tiny_httpd/Tiny_httpd_io/Out_channel/index.html
index 9ab67f15..77319b12 100644
--- a/dev/tiny_httpd/Tiny_httpd_io/Out_channel/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_io/Out_channel/index.html
@@ -1,2 +1,2 @@
-Out_channel (tiny_httpd.Tiny_httpd_io.Out_channel) Module Tiny_httpd_io.Out_channel
Output channel (byte sink)
type t = {output_char : char -> unit;(*Output a single char
*)output : bytes -> int -> int -> unit;(*Output slice
*)flush : unit -> unit;(*Flush underlying buffer
*)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 -> Stdlib.out_channel -> tof_out_channel oc wraps the channel into a Out_channel.t.
val of_buffer : Stdlib.Buffer.t -> tof_buffer buf is an output channel that writes directly into buf. flush and close have no effect.
val output_char : t -> char -> unitOutput the buffer slice into this channel
val output : t -> bytes -> int -> int -> unitOutput the buffer slice into this channel
val output_string : t -> string -> unitval close : t -> unitClose the channel.
val flush : t -> unitFlush (ie. force write) any buffered bytes.
\ No newline at end of file
+Out_channel (tiny_httpd.Tiny_httpd_io.Out_channel) Module Tiny_httpd_io.Out_channel
Output channel (byte sink)
type t = {output_char : char -> unit;(*Output a single char
*)output : bytes -> int -> int -> unit;(*Output slice
*)flush : unit -> unit;(*Flush underlying buffer
*)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 -> Stdlib.out_channel -> tof_out_channel oc wraps the channel into a Out_channel.t.
val of_buffer : Stdlib.Buffer.t -> tof_buffer buf is an output channel that writes directly into buf. flush and close have no effect.
val output_char : t -> char -> unitOutput the buffer slice into this channel
val output : t -> bytes -> int -> int -> unitOutput the buffer slice into this channel
val output_string : t -> string -> unitval close : t -> unitClose the channel.
val flush : t -> unitFlush (ie. force write) any buffered bytes.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html b/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html
index f6cb4b89..5d6007ac 100644
--- a/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html
@@ -1,2 +1,2 @@
-TCP_server (tiny_httpd.Tiny_httpd_io.TCP_server) Module Tiny_httpd_io.TCP_server
A TCP server abstraction.
type t = {endpoint : unit -> string * int;(*Endpoint we listen on. This can only be called from within serve.
*)active_connections : unit -> int;(*Number of connections currently active
*)running : unit -> bool;(*Is the server currently running?
*)stop : unit -> unit;(*Ask the server to stop. This might not take effect immediately, and is idempotent. After this server.running() must return false.
*)
}A running TCP server.
This contains some functions that provide information about the running server, including whether it's active (as opposed to stopped), a function to stop it, and statistics about the number of connections.
type builder = {serve : after_init:(t -> unit) -> handle:conn_handler -> unit -> unit;(*Blocking call to listen for incoming connections and handle them. Uses the connection handler handle to handle individual client connections in individual threads/fibers/tasks.
*)
}A TCP server builder implementation.
Calling builder.serve ~after_init ~handle () starts a new TCP server on an unspecified endpoint (most likely coming from the function returning this builder) and returns the running server.
\ No newline at end of file
+TCP_server (tiny_httpd.Tiny_httpd_io.TCP_server) Module Tiny_httpd_io.TCP_server
A TCP server abstraction.
type t = {endpoint : unit -> string * int;(*Endpoint we listen on. This can only be called from within serve.
*)active_connections : unit -> int;(*Number of connections currently active
*)running : unit -> bool;(*Is the server currently running?
*)stop : unit -> unit;(*Ask the server to stop. This might not take effect immediately, and is idempotent. After this server.running() must return false.
*)
}A running TCP server.
This contains some functions that provide information about the running server, including whether it's active (as opposed to stopped), a function to stop it, and statistics about the number of connections.
type builder = {serve : after_init:(t -> unit) -> handle:conn_handler -> unit -> unit;(*Blocking call to listen for incoming connections and handle them. Uses the connection handler handle to handle individual client connections in individual threads/fibers/tasks.
*)
}A TCP server builder implementation.
Calling builder.serve ~after_init ~handle () starts a new TCP server on an unspecified endpoint (most likely coming from the function returning this builder) and returns the running server.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html b/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html
index 0d020926..34bb813c 100644
--- a/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html
@@ -1,2 +1,2 @@
-Writer (tiny_httpd.Tiny_httpd_io.Writer) Module Tiny_httpd_io.Writer
A writer abstraction.
Writer.
A writer is a push-based stream of bytes. Give it an output channel and it will write the bytes in it.
This is useful for responses: an http endpoint can return a writer as its response's body, and output into it as if it were a regular out_channel, including controlling calls to flush.
val make : write:(Out_channel.t -> unit) -> unit -> tval write : Out_channel.t -> t -> unitWrite into the channel.
val empty : tEmpty writer, will output 0 bytes.
val of_string : string -> tA writer that just emits the bytes from the given string.
\ No newline at end of file
+Writer (tiny_httpd.Tiny_httpd_io.Writer) Module Tiny_httpd_io.Writer
A writer abstraction.
Writer.
A writer is a push-based stream of bytes. Give it an output channel and it will write the bytes in it.
This is useful for responses: an http endpoint can return a writer as its response's body, and output into it as if it were a regular out_channel, including controlling calls to flush.
val make : write:(Out_channel.t -> unit) -> unit -> tval write : Out_channel.t -> t -> unitWrite into the channel.
val empty : tEmpty writer, will output 0 bytes.
val of_string : string -> tA writer that just emits the bytes from the given string.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_io/index.html b/dev/tiny_httpd/Tiny_httpd_io/index.html
index 5debb293..21b119c8 100644
--- a/dev/tiny_httpd/Tiny_httpd_io/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_io/index.html
@@ -1,2 +1,2 @@
-Tiny_httpd_io (tiny_httpd.Tiny_httpd_io) Module Tiny_httpd_io
IO abstraction.
We abstract IO so we can support classic unix blocking IOs with threads, and modern async IO with Eio.
NOTE: experimental.
module Buf = Tiny_httpd_bufmodule In_channel : sig ... endInput channel (byte source)
module Out_channel : sig ... endOutput channel (byte sink)
module Writer : sig ... endA writer abstraction.
module TCP_server : sig ... endA TCP server abstraction.
\ No newline at end of file
+Tiny_httpd_io (tiny_httpd.Tiny_httpd_io) Module Tiny_httpd_io
IO abstraction.
We abstract IO so we can support classic unix blocking IOs with threads, and modern async IO with Eio.
NOTE: experimental.
module Buf = Tiny_httpd_bufmodule In_channel : sig ... endInput channel (byte source)
module Out_channel : sig ... endOutput channel (byte sink)
module Writer : sig ... endA writer abstraction.
module TCP_server : sig ... endA TCP server abstraction.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_pool/index.html b/dev/tiny_httpd/Tiny_httpd_pool/index.html
index 6e38e97e..95ecfe21 100644
--- a/dev/tiny_httpd/Tiny_httpd_pool/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_pool/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_pool (tiny_httpd.Tiny_httpd_pool) Module Tiny_httpd_pool
Resource pool.
This pool is used for buffers. It can be used for other resources but do note that it assumes resources are still reasonably cheap to produce and discard, and will never block waiting for a resource — it's not a good pool for DB connections.
val create :
+Tiny_httpd_pool (tiny_httpd.Tiny_httpd_pool) Module Tiny_httpd_pool
Resource pool.
This pool is used for buffers. It can be used for other resources but do note that it assumes resources are still reasonably cheap to produce and discard, and will never block waiting for a resource — it's not a good pool for DB connections.
val create :
?clear:('a -> unit) ->
mk_item:(unit -> 'a) ->
?max_size:int ->
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html b/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html
index 72efa1e4..f418a291 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html
@@ -1,2 +1,2 @@
-Headers (tiny_httpd.Tiny_httpd_server.Headers) Module Tiny_httpd_server.Headers
The header files of a request or response.
Neither the key nor the value can contain '\r' or '\n'. See https://tools.ietf.org/html/rfc7230#section-3.2
val empty : tEmpty list of headers.
val get : ?f:(string -> string) -> string -> t -> string optionget k headers looks for the header field with key k.
set k v headers sets the key k to value v. It erases any previous entry for k
val contains : string -> t -> boolIs there a header with the given key?
val pp : Stdlib.Format.formatter -> t -> unitPretty print the headers.
\ No newline at end of file
+Headers (tiny_httpd.Tiny_httpd_server.Headers) Module Tiny_httpd_server.Headers
The header files of a request or response.
Neither the key nor the value can contain '\r' or '\n'. See https://tools.ietf.org/html/rfc7230#section-3.2
val empty : tEmpty list of headers.
val get : ?f:(string -> string) -> string -> t -> string optionget k headers looks for the header field with key k.
set k v headers sets the key k to value v. It erases any previous entry for k
val contains : string -> t -> boolIs there a header with the given key?
val pp : Stdlib.Format.formatter -> t -> unitPretty print the headers.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html b/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html
index 02e4b4c0..b0b3305b 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html
@@ -1,2 +1,2 @@
-Meth (tiny_httpd.Tiny_httpd_server.Meth) Module Tiny_httpd_server.Meth
A HTTP method. For now we only handle a subset of these.
See https://tools.ietf.org/html/rfc7231#section-4
val pp : Stdlib.Format.formatter -> t -> unitval to_string : t -> string
\ No newline at end of file
+Meth (tiny_httpd.Tiny_httpd_server.Meth) Module Tiny_httpd_server.Meth
A HTTP method. For now we only handle a subset of these.
See https://tools.ietf.org/html/rfc7231#section-4
val pp : Stdlib.Format.formatter -> t -> unitval to_string : t -> string
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html b/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html
index 5a8ee6dd..70876c01 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html
@@ -1,2 +1,2 @@
-Middleware (tiny_httpd.Tiny_httpd_server.Middleware) Module Tiny_httpd_server.Middleware
type handler = byte_stream Request.t -> resp:(Response.t -> unit) -> unitHandlers are functions returning a response to a request. The response can be delayed, hence the use of a continuation as the resp parameter.
A middleware is a handler transformation.
It takes the existing handler h, and returns a new one which, given a query, modify it or log it before passing it to h, or fail. It can also log or modify or drop the response.
val nil : tTrivial middleware that does nothing.
\ No newline at end of file
+Middleware (tiny_httpd.Tiny_httpd_server.Middleware) Module Tiny_httpd_server.Middleware
type handler = byte_stream Request.t -> resp:(Response.t -> unit) -> unitHandlers are functions returning a response to a request. The response can be delayed, hence the use of a continuation as the resp parameter.
A middleware is a handler transformation.
It takes the existing handler h, and returns a new one which, given a query, modify it or log it before passing it to h, or fail. It can also log or modify or drop the response.
val nil : tTrivial middleware that does nothing.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Request/index.html b/dev/tiny_httpd/Tiny_httpd_server/Request/index.html
index 9bf6ffcf..5af27b92 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Request/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Request/index.html
@@ -1,5 +1,5 @@
-Request (tiny_httpd.Tiny_httpd_server.Request) Module Tiny_httpd_server.Request
type 'body t = private {meth : Meth.t;(*HTTP method for this request.
*)host : string;headers : Headers.t;(*List of headers.
*)http_version : int * int;(*HTTP version. This should be either 1, 0 or 1, 1.
*)path : string;(*Full path of the requested URL.
*)path_components : string list;(*Components of the path of the requested URL.
*)query : (string * string) list;(*Query part of the requested URL.
*)body : 'body;(*Body of the request.
*)start_time : float;
}A request with method, path, host, headers, and a body, sent by a client.
The body is polymorphic because the request goes through several transformations. First it has no body, as only the request and headers are read; then it has a stream body; then the body might be entirely read as a string via read_body_full.
val pp : Stdlib.Format.formatter -> string t -> unitPretty print the request and its body. The exact format of this printing is not specified.
val pp_ : Stdlib.Format.formatter -> _ t -> unitPretty print the request without its body. The exact format of this printing is not specified.
val get_header : ?f:(string -> string) -> _ t -> string -> string optionget_header req h looks up header h in req. It returns None if the header is not present. This is case insensitive and should be used rather than looking up h verbatim in headers.
val get_header_int : _ t -> string -> int optionSame as get_header but also performs a string to integer conversion.
set_header k v req sets k: v in the request req's headers.
Modify headers using the given function.
val host : _ t -> stringHost field of the request. It also appears in the headers.
val path : _ t -> stringRequest path.
val body : 'b t -> 'bRequest body, possibly empty.
val start_time : _ t -> floattime stamp (from Unix.gettimeofday) after parsing the first line of the request
val limit_body_size : max_size:int -> byte_stream t -> byte_stream tLimit the body size to max_size bytes, or return a 413 error.
val read_body_full :
+Request (tiny_httpd.Tiny_httpd_server.Request) Module Tiny_httpd_server.Request
type 'body t = private {meth : Meth.t;(*HTTP method for this request.
*)host : string;headers : Headers.t;(*List of headers.
*)http_version : int * int;(*HTTP version. This should be either 1, 0 or 1, 1.
*)path : string;(*Full path of the requested URL.
*)path_components : string list;(*Components of the path of the requested URL.
*)query : (string * string) list;(*Query part of the requested URL.
*)body : 'body;(*Body of the request.
*)start_time : float;
}A request with method, path, host, headers, and a body, sent by a client.
The body is polymorphic because the request goes through several transformations. First it has no body, as only the request and headers are read; then it has a stream body; then the body might be entirely read as a string via read_body_full.
val pp : Stdlib.Format.formatter -> string t -> unitPretty print the request and its body. The exact format of this printing is not specified.
val pp_ : Stdlib.Format.formatter -> _ t -> unitPretty print the request without its body. The exact format of this printing is not specified.
val get_header : ?f:(string -> string) -> _ t -> string -> string optionget_header req h looks up header h in req. It returns None if the header is not present. This is case insensitive and should be used rather than looking up h verbatim in headers.
val get_header_int : _ t -> string -> int optionSame as get_header but also performs a string to integer conversion.
set_header k v req sets k: v in the request req's headers.
Modify headers using the given function.
val host : _ t -> stringHost field of the request. It also appears in the headers.
val path : _ t -> stringRequest path.
val body : 'b t -> 'bRequest body, possibly empty.
val start_time : _ t -> floattime stamp (from Unix.gettimeofday) after parsing the first line of the request
val limit_body_size : max_size:int -> byte_stream t -> byte_stream tLimit the body size to max_size bytes, or return a 413 error.
val read_body_full :
?buf:Tiny_httpd_buf.t ->
?buf_size:int ->
byte_stream t ->
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Response/index.html b/dev/tiny_httpd/Tiny_httpd_server/Response/index.html
index b5c6e241..1ead6ece 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Response/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Response/index.html
@@ -1,19 +1,23 @@
-Response (tiny_httpd.Tiny_httpd_server.Response) Module Tiny_httpd_server.Response
type body = [ | `String of string| `Stream of byte_stream| `Writer of Tiny_httpd_io.Writer.t| `Void
]Body of a response, either as a simple string, or a stream of bytes, or nothing (for server-sent events notably).
`String str replies with a body set to this string, and a known content-length.`Stream str replies with a body made from this string, using chunked encoding.`Void replies with no body.`Writer w replies with a body created by the writer w, using a chunked encoding. It is available since NEXT_RELEASE.
type t = private {code : Response_code.t;headers : Headers.t;(*Headers of the reply. Some will be set by Tiny_httpd automatically.
*)body : body;(*Body of the response. Can be empty.
*)
}A response to send back to a client.
val set_code : Response_code.t -> t -> tSet the response code.
val make_raw : ?headers:Headers.t -> code:Response_code.t -> string -> tMake a response from its raw components, with a string body. Use "" to not send a body at all.
val make_raw_stream :
+Response (tiny_httpd.Tiny_httpd_server.Response) Module Tiny_httpd_server.Response
type body = [ | `String of string| `Stream of byte_stream| `Writer of Tiny_httpd_io.Writer.t| `Void
]Body of a response, either as a simple string, or a stream of bytes, or nothing (for server-sent events notably).
`String str replies with a body set to this string, and a known content-length.`Stream str replies with a body made from this string, using chunked encoding.`Void replies with no body.`Writer w replies with a body created by the writer w, using a chunked encoding. It is available since NEXT_RELEASE.
type t = private {code : Response_code.t;headers : Headers.t;(*Headers of the reply. Some will be set by Tiny_httpd automatically.
*)body : body;(*Body of the response. Can be empty.
*)
}A response to send back to a client.
val set_code : Response_code.t -> t -> tSet the response code.
val make_raw : ?headers:Headers.t -> code:Response_code.t -> string -> tMake a response from its raw components, with a string body. Use "" to not send a body at all.
val make_raw_stream :
?headers:Headers.t ->
code:Response_code.t ->
byte_stream ->
tSame as make_raw but with a stream body. The body will be sent with the chunked transfer-encoding.
val make :
?headers:Headers.t ->
+ ?code:int ->
(body, Response_code.t * string) Stdlib.result ->
tmake r turns a result into a response.
make (Ok body) replies with 200 and the body.make (Error (code,msg)) replies with the given error code and message as body.
val make_string :
?headers:Headers.t ->
+ ?code:int ->
(string, Response_code.t * string) Stdlib.result ->
tSame as make but with a string body.
val make_writer :
?headers:Headers.t ->
+ ?code:int ->
(Tiny_httpd_io.Writer.t, Response_code.t * string) Stdlib.result ->
tSame as make but with a writer body.
val make_stream :
?headers:Headers.t ->
+ ?code:int ->
(byte_stream, Response_code.t * string) Stdlib.result ->
tSame as make but with a stream body.
val fail :
?headers:Headers.t ->
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html b/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html
index 587eeccd..6e84933a 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html
@@ -1,2 +1,2 @@
-Response_code (tiny_httpd.Tiny_httpd_server.Response_code) Module Tiny_httpd_server.Response_code
val ok : tThe code 200
val not_found : tThe code 404
val descr : t -> stringA description of some of the error codes. NOTE: this is not complete (yet).
\ No newline at end of file
+Response_code (tiny_httpd.Tiny_httpd_server.Response_code) Module Tiny_httpd_server.Response_code
val ok : tThe code 200
val not_found : tThe code 404
val descr : t -> stringA description of some of the error codes. NOTE: this is not complete (yet).
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/Route/index.html b/dev/tiny_httpd/Tiny_httpd_server/Route/index.html
index 4f44e13e..25f6f090 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/Route/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/Route/index.html
@@ -1,2 +1,2 @@
-Route (tiny_httpd.Tiny_httpd_server.Route) Module Tiny_httpd_server.Route
val int : (int -> 'a, 'a) compMatches an integer.
val string : (string -> 'a, 'a) compMatches a string not containing '/' and binds it as is.
val string_urlencoded : (string -> 'a, 'a) compMatches a URL-encoded string, and decodes it.
val exact : string -> ('a, 'a) compexact "s" matches "s" and nothing else.
val return : ('a, 'a) tMatches the empty path.
val rest_of_path : (string -> 'a, 'a) tMatches a string, even containing '/'. This will match the entirety of the remaining route.
val rest_of_path_urlencoded : (string -> 'a, 'a) tMatches a string, even containing '/', an URL-decode it. This will match the entirety of the remaining route.
comp / route matches "foo/bar/…" iff comp matches "foo", and route matches "bar/…".
exact_path "foo/bar/..." r is equivalent to exact "foo" @/ exact "bar" @/ ... @/ r
val pp : Stdlib.Format.formatter -> (_, _) t -> unitPrint the route.
val to_string : (_, _) t -> stringPrint the route.
\ No newline at end of file
+Route (tiny_httpd.Tiny_httpd_server.Route) Module Tiny_httpd_server.Route
val int : (int -> 'a, 'a) compMatches an integer.
val string : (string -> 'a, 'a) compMatches a string not containing '/' and binds it as is.
val string_urlencoded : (string -> 'a, 'a) compMatches a URL-encoded string, and decodes it.
val exact : string -> ('a, 'a) compexact "s" matches "s" and nothing else.
val return : ('a, 'a) tMatches the empty path.
val rest_of_path : (string -> 'a, 'a) tMatches a string, even containing '/'. This will match the entirety of the remaining route.
val rest_of_path_urlencoded : (string -> 'a, 'a) tMatches a string, even containing '/', an URL-decode it. This will match the entirety of the remaining route.
comp / route matches "foo/bar/…" iff comp matches "foo", and route matches "bar/…".
exact_path "foo/bar/..." r is equivalent to exact "foo" @/ exact "bar" @/ ... @/ r
val pp : Stdlib.Format.formatter -> (_, _) t -> unitPrint the route.
val to_string : (_, _) t -> stringPrint the route.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/index.html b/dev/tiny_httpd/Tiny_httpd_server/index.html
index 096bd777..70599ed3 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_server (tiny_httpd.Tiny_httpd_server) Module Tiny_httpd_server
HTTP server.
This module implements a very simple, basic HTTP/1.1 server using blocking IOs and threads.
It is possible to use a thread pool, see create's argument new_thread.
type buf = Tiny_httpd_buf.ttype byte_stream = Tiny_httpd_stream.tHTTP Methods
module Meth : sig ... endHeaders
Headers are metadata associated with a request or response.
module Headers : sig ... endRequests
Requests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
module Request : sig ... endResponse Codes
module Response_code : sig ... endResponses
Responses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
module Response : sig ... endRouting
Basic type-safe routing of handlers based on URL paths. This is optional, it is possible to only define the root handler with something like Routes.
module Route : sig ... endMiddlewares
A middleware can be inserted in a handler to modify or observe its behavior.
module Middleware : sig ... endMain Server type
A HTTP server. See create for more details.
val create :
+Tiny_httpd_server (tiny_httpd.Tiny_httpd_server) Module Tiny_httpd_server
HTTP server.
This module implements a very simple, basic HTTP/1.1 server using blocking IOs and threads.
It is possible to use a thread pool, see create's argument new_thread.
type buf = Tiny_httpd_buf.ttype byte_stream = Tiny_httpd_stream.tHTTP Methods
module Meth : sig ... endHeaders
Headers are metadata associated with a request or response.
module Headers : sig ... endRequests
Requests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
module Request : sig ... endResponse Codes
module Response_code : sig ... endResponses
Responses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
module Response : sig ... endRouting
Basic type-safe routing of handlers based on URL paths. This is optional, it is possible to only define the root handler with something like Routes.
module Route : sig ... endMiddlewares
A middleware can be inserted in a handler to modify or observe its behavior.
module Middleware : sig ... endMain Server type
A HTTP server. See create for more details.
val create :
?masksigpipe:bool ->
?max_connections:int ->
?timeout:float ->
diff --git a/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html b/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html
index ba821ed3..a012de2f 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html
@@ -1,2 +1,2 @@
-IO_BACKEND (tiny_httpd.Tiny_httpd_server.IO_BACKEND) Module type Tiny_httpd_server.IO_BACKEND
A backend that provides IO operations, network operations, etc.
This is used to decouple tiny_httpd from the scheduler/IO library used to actually open a TCP server and talk to clients. The classic way is based on Unix and blocking IOs, but it's also possible to use an OCaml 5 library using effects and non blocking IOs.
val tcp_server : unit -> Tiny_httpd_io.TCP_server.builderTCP server builder, to create servers that can listen on a port and handle clients.
\ No newline at end of file
+IO_BACKEND (tiny_httpd.Tiny_httpd_server.IO_BACKEND) Module type Tiny_httpd_server.IO_BACKEND
A backend that provides IO operations, network operations, etc.
This is used to decouple tiny_httpd from the scheduler/IO library used to actually open a TCP server and talk to clients. The classic way is based on Unix and blocking IOs, but it's also possible to use an OCaml 5 library using effects and non blocking IOs.
val tcp_server : unit -> Tiny_httpd_io.TCP_server.builderTCP server builder, to create servers that can listen on a port and handle clients.
\ No newline at end of file
diff --git a/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html b/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html
index 225e4a60..7f729f5c 100644
--- a/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html
@@ -1,5 +1,5 @@
-SERVER_SENT_GENERATOR (tiny_httpd.Tiny_httpd_server.SERVER_SENT_GENERATOR) Module type Tiny_httpd_server.SERVER_SENT_GENERATOR
A server-side function to generate of Server-sent events.
See the w3c page and this blog post.
val set_headers : Headers.t -> unitSet headers of the response. This is not mandatory but if used at all, it must be called before any call to send_event (once events are sent the response is already sent too).
val send_event :
+SERVER_SENT_GENERATOR (tiny_httpd.Tiny_httpd_server.SERVER_SENT_GENERATOR) Module type Tiny_httpd_server.SERVER_SENT_GENERATOR
A server-side function to generate of Server-sent events.
See the w3c page and this blog post.
val set_headers : Headers.t -> unitSet headers of the response. This is not mandatory but if used at all, it must be called before any call to send_event (once events are sent the response is already sent too).
val send_event :
?event:string ->
?id:string ->
?retry:string ->
diff --git a/dev/tiny_httpd/Tiny_httpd_stream/index.html b/dev/tiny_httpd/Tiny_httpd_stream/index.html
index ce448efe..dc6a8729 100644
--- a/dev/tiny_httpd/Tiny_httpd_stream/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_stream/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_stream (tiny_httpd.Tiny_httpd_stream) Module Tiny_httpd_stream
Byte streams.
Streams are used to represent a series of bytes that can arrive progressively. For example, an uploaded file will be sent as a series of chunks.
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 is bytes[i] .. [bytes[i+len-1]]. Can block to refill the buffer if there is currently no content. If len=0 then there is no more data.
*)consume : int -> unit;(*Consume n bytes from the buffer. This should only be called with n <= 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.
The point of this type is that it gives the caller access to its internal buffer (bs, with the slice off,len). This is convenient for things like line reading where one needs to peek ahead.
Some core invariant for this type of stream are:
off,len delimits a valid slice in bs (indices: off, off+1, … off+len-1)- if
fill_buf() was just called, then either len=0 which indicates the end of stream; or len>0 and the slice contains some data.
To actually move forward in the stream, you can call consume n to consume n bytes (where n <= len). If len gets to 0, calling fill_buf() is required, so it can try to obtain a new slice.
To emulate a classic OCaml reader with a read: bytes -> int -> int -> int function, the simplest is:
let read (self:t) buf offset max_len : int =
+Tiny_httpd_stream (tiny_httpd.Tiny_httpd_stream) Module Tiny_httpd_stream
Byte streams.
Streams are used to represent a series of bytes that can arrive progressively. For example, an uploaded file will be sent as a series of chunks.
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 is bytes[i] .. [bytes[i+len-1]]. Can block to refill the buffer if there is currently no content. If len=0 then there is no more data.
*)consume : int -> unit;(*Consume n bytes from the buffer. This should only be called with n <= 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.
The point of this type is that it gives the caller access to its internal buffer (bs, with the slice off,len). This is convenient for things like line reading where one needs to peek ahead.
Some core invariant for this type of stream are:
off,len delimits a valid slice in bs (indices: off, off+1, … off+len-1)- if
fill_buf() was just called, then either len=0 which indicates the end of stream; or len>0 and the slice contains some data.
To actually move forward in the stream, you can call consume n to consume n bytes (where n <= len). If len gets to 0, calling fill_buf() is required, so it can try to obtain a new slice.
To emulate a classic OCaml reader with a read: bytes -> int -> int -> int function, the simplest is:
let read (self:t) buf offset max_len : int =
self.fill_buf();
let len = min max_len self.len in
if len > 0 then (
diff --git a/dev/tiny_httpd/Tiny_httpd_util/index.html b/dev/tiny_httpd/Tiny_httpd_util/index.html
index 16ac2da7..aa681744 100644
--- a/dev/tiny_httpd/Tiny_httpd_util/index.html
+++ b/dev/tiny_httpd/Tiny_httpd_util/index.html
@@ -1,2 +1,2 @@
-Tiny_httpd_util (tiny_httpd.Tiny_httpd_util) Module Tiny_httpd_util
Some utils for writing web servers
Encode the string into a valid path following https://tools.ietf.org/html/rfc3986#section-2.1
Inverse operation of percent_encode. Can fail since some strings are not valid percent encodings.
\ No newline at end of file
+Tiny_httpd_util (tiny_httpd.Tiny_httpd_util) Module Tiny_httpd_util
Some utils for writing web servers
Encode the string into a valid path following https://tools.ietf.org/html/rfc3986#section-2.1
Inverse operation of percent_encode. Can fail since some strings are not valid percent encodings.
\ No newline at end of file
diff --git a/dev/tiny_httpd/index.html b/dev/tiny_httpd/index.html
index 7c2791ca..60b4ecd2 100644
--- a/dev/tiny_httpd/index.html
+++ b/dev/tiny_httpd/index.html
@@ -1,2 +1,2 @@
-index (tiny_httpd.index) tiny_httpd index
Library tiny_httpd
This library exposes the following toplevel modules:
Tiny_httpd Tiny Http ServerTiny_httpd_atomic_ Tiny_httpd_buf Simple buffer.Tiny_httpd_dir Serving static content from directoriesTiny_httpd_html HTML combinators.Tiny_httpd_html_ Tiny_httpd_io IO abstraction.Tiny_httpd_pool Resource pool.Tiny_httpd_server HTTP server.Tiny_httpd_stream Byte streams.Tiny_httpd_util
\ No newline at end of file
+index (tiny_httpd.index) tiny_httpd index
Library tiny_httpd
This library exposes the following toplevel modules:
Tiny_httpd Tiny Http ServerTiny_httpd_atomic_ Tiny_httpd_buf Simple buffer.Tiny_httpd_dir Serving static content from directoriesTiny_httpd_html HTML combinators.Tiny_httpd_html_ Tiny_httpd_io IO abstraction.Tiny_httpd_pool Resource pool.Tiny_httpd_server HTTP server.Tiny_httpd_stream Byte streams.Tiny_httpd_util
\ No newline at end of file
diff --git a/dev/tiny_httpd_camlzip/Tiny_httpd_camlzip/index.html b/dev/tiny_httpd_camlzip/Tiny_httpd_camlzip/index.html
index 81c20436..6bde9437 100644
--- a/dev/tiny_httpd_camlzip/Tiny_httpd_camlzip/index.html
+++ b/dev/tiny_httpd_camlzip/Tiny_httpd_camlzip/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_camlzip (tiny_httpd_camlzip.Tiny_httpd_camlzip) Module Tiny_httpd_camlzip
Middleware for compression.
This uses camlzip to provide deflate compression/decompression. If installed, the middleware will compress responses' bodies when they are streams or fixed-size above a given limit (but it will not compress small, fixed-size bodies).
val middleware :
+Tiny_httpd_camlzip (tiny_httpd_camlzip.Tiny_httpd_camlzip) Module Tiny_httpd_camlzip
Middleware for compression.
This uses camlzip to provide deflate compression/decompression. If installed, the middleware will compress responses' bodies when they are streams or fixed-size above a given limit (but it will not compress small, fixed-size bodies).
val middleware :
?compress_above:int ->
?buf_size:int ->
unit ->
diff --git a/dev/tiny_httpd_camlzip/index.html b/dev/tiny_httpd_camlzip/index.html
index 47a8f23a..cbae8b9b 100644
--- a/dev/tiny_httpd_camlzip/index.html
+++ b/dev/tiny_httpd_camlzip/index.html
@@ -1,2 +1,2 @@
-index (tiny_httpd_camlzip.index) tiny_httpd_camlzip index
Library tiny_httpd_camlzip
The entry point of this library is the module: Tiny_httpd_camlzip.
\ No newline at end of file
+index (tiny_httpd_camlzip.index) tiny_httpd_camlzip index
Library tiny_httpd_camlzip
The entry point of this library is the module: Tiny_httpd_camlzip.
\ No newline at end of file
diff --git a/dev/tiny_httpd_eio/Tiny_httpd_eio/index.html b/dev/tiny_httpd_eio/Tiny_httpd_eio/index.html
index 06f5f37e..5fb4a32f 100644
--- a/dev/tiny_httpd_eio/Tiny_httpd_eio/index.html
+++ b/dev/tiny_httpd_eio/Tiny_httpd_eio/index.html
@@ -1,5 +1,5 @@
-Tiny_httpd_eio (tiny_httpd_eio.Tiny_httpd_eio) Module Tiny_httpd_eio
Tiny httpd EIO backend.
This replaces the threads + Unix blocking syscalls of Tiny_httpd_server with an Eio-based cooperative system.
NOTE: this is very experimental and will absolutely change over time, especially since Eio itself is also subject to change.
type 'a with_args =
+Tiny_httpd_eio (tiny_httpd_eio.Tiny_httpd_eio) Module Tiny_httpd_eio
Tiny httpd EIO backend.
This replaces the threads + Unix blocking syscalls of Tiny_httpd_server with an Eio-based cooperative system.
NOTE: this is very experimental and will absolutely change over time, especially since Eio itself is also subject to change.
type 'a with_args =
?addr:string ->
?port:int ->
?max_connections:int ->
diff --git a/dev/tiny_httpd_eio/index.html b/dev/tiny_httpd_eio/index.html
index 11b7f7f1..099bdc49 100644
--- a/dev/tiny_httpd_eio/index.html
+++ b/dev/tiny_httpd_eio/index.html
@@ -1,2 +1,2 @@
-index (tiny_httpd_eio.index) tiny_httpd_eio index
Library tiny_httpd_eio
The entry point of this library is the module: Tiny_httpd_eio.
\ No newline at end of file
+index (tiny_httpd_eio.index) tiny_httpd_eio index
Library tiny_httpd_eio
The entry point of this library is the module: Tiny_httpd_eio.
\ No newline at end of file