diff --git a/tiny_httpd/Tiny_httpd/index.html b/tiny_httpd/Tiny_httpd/index.html index d2727499..ed02f451 100644 --- a/tiny_httpd/Tiny_httpd/index.html +++ b/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 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/tiny_httpd/Tiny_httpd_io/Input/index.html b/tiny_httpd/Tiny_httpd_io/Input/index.html
index e1303293..20b2d40d 100644
--- a/tiny_httpd/Tiny_httpd_io/Input/index.html
+++ b/tiny_httpd/Tiny_httpd_io/Input/index.html
@@ -1,2 +1,2 @@
-Input (tiny_httpd.Tiny_httpd_io.Input) Module Tiny_httpd_io.Input
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 -> in_channel -> tval of_unix_fd : ?close_noerr:bool -> Unix.file_descr -> tval of_slice : bytes -> int -> int -> tval input : t -> bytes -> int -> int -> intRead into the given slice.
val really_input : t -> bytes -> int -> int -> unitRead exactly len bytes.
val close : t -> unitClose the channel.
+Input (tiny_httpd.Tiny_httpd_io.Input) Module Tiny_httpd_io.Input
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 -> in_channel -> tval of_unix_fd : ?close_noerr:bool -> closed:bool ref -> Unix.file_descr -> tval of_slice : bytes -> int -> int -> tval input : t -> bytes -> int -> int -> intRead into the given slice.
val really_input : t -> bytes -> int -> int -> unitRead exactly len bytes.
val close : t -> unitClose the channel.
diff --git a/tiny_httpd/Tiny_httpd_io/Output/index.html b/tiny_httpd/Tiny_httpd_io/Output/index.html
index c0e31c32..8abcbcae 100644
--- a/tiny_httpd/Tiny_httpd_io/Output/index.html
+++ b/tiny_httpd/Tiny_httpd_io/Output/index.html
@@ -1,2 +1,7 @@
-Output (tiny_httpd.Tiny_httpd_io.Output) Module Tiny_httpd_io.Output
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 -> out_channel -> tof_out_channel oc wraps the channel into a Output.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.
+Output (tiny_httpd.Tiny_httpd_io.Output) Module Tiny_httpd_io.Output
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_unix_fd :
+ ?close_noerr:bool ->
+ closed:bool ref ->
+ buf:Buf.t ->
+ Unix.file_descr ->
+ tval of_out_channel : ?close_noerr:bool -> out_channel -> tof_out_channel oc wraps the channel into a Output.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.
diff --git a/tiny_httpd/Tiny_httpd_server/Request/index.html b/tiny_httpd/Tiny_httpd_server/Request/index.html
index 60d386c5..61e5ed9f 100644
--- a/tiny_httpd/Tiny_httpd_server/Request/index.html
+++ b/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;client_addr : Unix.sockaddr;(*Client address. Available since 0.14.
*)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 client_addr : _ t -> Unix.sockaddrClient address of the request.
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;client_addr : Unix.sockaddr;(*Client address. Available since 0.14.
*)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 client_addr : _ t -> Unix.sockaddrClient address of the request.
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/tiny_httpd/Tiny_httpd_server/Response/index.html b/tiny_httpd/Tiny_httpd_server/Response/index.html
index db3fcf8e..c2020022 100644
--- a/tiny_httpd/Tiny_httpd_server/Response/index.html
+++ b/tiny_httpd/Tiny_httpd_server/Response/index.html
@@ -1,5 +1,5 @@
-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 0.14.
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 0.14.
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 ->
diff --git a/tiny_httpd/Tiny_httpd_stream/index.html b/tiny_httpd/Tiny_httpd_stream/index.html
index d935611b..4fbc2908 100644
--- a/tiny_httpd/Tiny_httpd_stream/index.html
+++ b/tiny_httpd/Tiny_httpd_stream/index.html
@@ -6,7 +6,11 @@
Bytes.blit self.bs self.off buf offset len;
self.consume len;
);
- lenval close : t -> unitClose stream
val empty : tStream with 0 bytes inside
val of_input : ?buf_size:int -> Tiny_httpd_io.Input.t -> tMake a buffered stream from the given channel.
val of_chan : ?buf_size:int -> in_channel -> tMake a buffered stream from the given channel.
val of_chan_close_noerr : ?buf_size:int -> in_channel -> tSame as of_chan but the close method will never fail.
val of_fd : ?buf_size:int -> Unix.file_descr -> tMake a buffered stream from the given file descriptor.
val of_fd_close_noerr : ?buf_size:int -> Unix.file_descr -> tSame as of_fd but the close method will never fail.
val of_bytes : ?i:int -> ?len:int -> bytes -> tA stream that just returns the slice of bytes starting from i and of length len.
val of_string : string -> tval iter : (bytes -> int -> int -> unit) -> t -> unitIterate on the chunks of the stream
val to_chan : out_channel -> t -> unitWrite the stream to the channel.
val to_chan' : Tiny_httpd_io.Output.t -> t -> unitWrite to the IO channel.
val to_writer : t -> Tiny_httpd_io.Writer.tTurn this stream into a writer.
val close : t -> unitClose stream
val empty : tStream with 0 bytes inside
val of_input : ?buf_size:int -> Tiny_httpd_io.Input.t -> tMake a buffered stream from the given channel.
val of_chan : ?buf_size:int -> in_channel -> tMake a buffered stream from the given channel.
val of_chan_close_noerr : ?buf_size:int -> in_channel -> tSame as of_chan but the close method will never fail.
val of_fd : ?buf_size:int -> closed:bool ref -> Unix.file_descr -> tMake a buffered stream from the given file descriptor.
val of_fd_close_noerr :
+ ?buf_size:int ->
+ closed:bool ref ->
+ Unix.file_descr ->
+ tSame as of_fd but the close method will never fail.
val of_bytes : ?i:int -> ?len:int -> bytes -> tA stream that just returns the slice of bytes starting from i and of length len.
val of_string : string -> tval iter : (bytes -> int -> int -> unit) -> t -> unitIterate on the chunks of the stream
val to_chan : out_channel -> t -> unitWrite the stream to the channel.
val to_chan' : Tiny_httpd_io.Output.t -> t -> unitWrite to the IO channel.
val to_writer : t -> Tiny_httpd_io.Writer.tTurn this stream into a writer.