diff --git a/tiny_httpd/Tiny_httpd/index.html b/tiny_httpd/Tiny_httpd/index.html index 2e634227..73a277b5 100644 --- a/tiny_httpd/Tiny_httpd/index.html +++ b/tiny_httpd/Tiny_httpd/index.html @@ -105,7 +105,7 @@ echo: ('a, string Tiny_httpd_core.Request.t -> server_sent_generator -> unit) Tiny_httpd_core.Route.t -> 'a -> - unit
Add a handler on an endpoint, that serves server-sent events.
The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.
This handler stays on the original thread (it is synchronous).
These handlers upgrade the connection to another protocol.
module type UPGRADE_HANDLER = Server.UPGRADE_HANDLERHandler that upgrades to another protocol.
type upgrade_handler = (module UPGRADE_HANDLER)Add a handler on an endpoint, that serves server-sent events.
The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.
This handler stays on the original thread (it is synchronous).
These handlers upgrade the connection to another protocol.
module type UPGRADE_HANDLER = Server.UPGRADE_HANDLERHandler that upgrades to another protocol.
type upgrade_handler = (module UPGRADE_HANDLER)val add_upgrade_handler :
?accept:
(unit Tiny_httpd_core.Request.t ->
(unit, Tiny_httpd_core.Response_code.t * string) result) ->
diff --git a/tiny_httpd/Tiny_httpd_core/Request/index.html b/tiny_httpd/Tiny_httpd_core/Request/index.html
index abe30a86..718f6ce5 100644
--- a/tiny_httpd/Tiny_httpd_core/Request/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Request/index.html
@@ -1,5 +1,5 @@
-Request (tiny_httpd.Tiny_httpd_core.Request) Module Tiny_httpd_core.Request
Requests
Requests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
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.
*)mutable meta : Hmap.t;(*Metadata.
*)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;(*Obtained via get_time_s in create
*)
}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_with :
+Request (tiny_httpd.Tiny_httpd_core.Request) Module Tiny_httpd_core.Request
Requests
Requests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
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.
*)mutable meta : Hmap.t;(*Metadata.
*)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;(*Obtained via get_time_s in create
*)
}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_with :
?mask_header:(string -> bool) ->
?headers_to_mask:string list ->
?show_query:bool ->
@@ -7,7 +7,7 @@
unit ->
Stdlib.Format.formatter ->
'body t ->
- unitPretty print the request. The exact format of this printing is not specified.
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
Pretty print the request. The exact format of this printing is not specified.
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 ->
bytes:bytes ->
IO.Input.t t ->
diff --git a/tiny_httpd/Tiny_httpd_core/Response/index.html b/tiny_httpd/Tiny_httpd_core/Response/index.html
index b1e40220..03585fd4 100644
--- a/tiny_httpd/Tiny_httpd_core/Response/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Response/index.html
@@ -1,5 +1,5 @@
-Response (tiny_httpd.Tiny_httpd_core.Response) Module Tiny_httpd_core.Response
Responses
Responses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
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_core.Response) Module Tiny_httpd_core.Response
Responses
Responses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
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 ->
IO.Input.t ->
diff --git a/tiny_httpd/Tiny_httpd_core/Response_code/index.html b/tiny_httpd/Tiny_httpd_core/Response_code/index.html
index f59dc6e3..c031eb82 100644
--- a/tiny_httpd/Tiny_httpd_core/Response_code/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Response_code/index.html
@@ -1,2 +1,2 @@
-Response_code (tiny_httpd.Tiny_httpd_core.Response_code) Module Tiny_httpd_core.Response_code
Response Codes
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).
val is_success : t -> boolis_success code is true iff code is in the 2xx or 3xx range.
+Response_code (tiny_httpd.Tiny_httpd_core.Response_code) Module Tiny_httpd_core.Response_code
Response Codes
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).
val is_success : t -> boolis_success code is true iff code is in the 2xx or 3xx range.
diff --git a/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html b/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html
index fa947a25..a8a8e486 100644
--- a/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html
@@ -1,2 +1,2 @@
-Head_middleware (tiny_httpd.Tiny_httpd_core.Server.Head_middleware) Module Server.Head_middleware
A middleware that only considers the request's head+headers.
These middlewares are simpler than full Middleware.t and work in more contexts.
A handler that takes the request, without its body, and possibly modifies it.
val trivial : tPass through
val to_middleware : t -> Middleware.t
+Head_middleware (tiny_httpd.Tiny_httpd_core.Server.Head_middleware) Module Server.Head_middleware
A middleware that only considers the request's head+headers.
These middlewares are simpler than full Middleware.t and work in more contexts.
A handler that takes the request, without its body, and possibly modifies it.
val trivial : tPass through
val to_middleware : t -> Middleware.t
diff --git a/tiny_httpd/Tiny_httpd_core/Server/index.html b/tiny_httpd/Tiny_httpd_core/Server/index.html
index 3e549ede..3a5da2d2 100644
--- a/tiny_httpd/Tiny_httpd_core/Server/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Server/index.html
@@ -34,7 +34,7 @@
t ->
('a, string Request.t -> server_sent_generator -> unit) Route.t ->
'a ->
- unitAdd a handler on an endpoint, that serves server-sent events.
The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.
This handler stays on the original thread (it is synchronous).
Upgrade handlers
These handlers upgrade the connection to another protocol.
module type UPGRADE_HANDLER = sig ... endHandler that upgrades to another protocol.
type upgrade_handler = (module UPGRADE_HANDLER)Add a handler on an endpoint, that serves server-sent events.
The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.
This handler stays on the original thread (it is synchronous).
Upgrade handlers
These handlers upgrade the connection to another protocol.
module type UPGRADE_HANDLER = sig ... endHandler that upgrades to another protocol.
type upgrade_handler = (module UPGRADE_HANDLER)val add_upgrade_handler :
?accept:(unit Request.t -> (unit, Response_code.t * string) result) ->
?middlewares:Head_middleware.t list ->
t ->
diff --git a/tiny_httpd/Tiny_httpd_core/Server/module-type-UPGRADE_HANDLER/index.html b/tiny_httpd/Tiny_httpd_core/Server/module-type-UPGRADE_HANDLER/index.html
index 73171390..061bfa6c 100644
--- a/tiny_httpd/Tiny_httpd_core/Server/module-type-UPGRADE_HANDLER/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Server/module-type-UPGRADE_HANDLER/index.html
@@ -1,5 +1,5 @@
-UPGRADE_HANDLER (tiny_httpd.Tiny_httpd_core.Server.UPGRADE_HANDLER) Module type Server.UPGRADE_HANDLER
Handler that upgrades to another protocol.
val handshake :
+UPGRADE_HANDLER (tiny_httpd.Tiny_httpd_core.Server.UPGRADE_HANDLER) Module type Server.UPGRADE_HANDLER
Handler that upgrades to another protocol.
val handshake :
Unix.sockaddr ->
unit Request.t ->
(Headers.t * handshake_state, string) resultPerform the handshake and upgrade the connection. This returns either Ok (resp_headers, state) in case of success, in which case the server sends a 101 response with resp_headers; or it returns Error log_msg if the the handshake fails, in which case the connection is closed without further ado and log_msg is logged locally (but not returned to the client).
val handle_connection : handshake_state -> IO.Input.t -> IO.Output.t -> unitTake control of the connection and take it from ther.e
diff --git a/tiny_httpd/Tiny_httpd_core/Util/index.html b/tiny_httpd/Tiny_httpd_core/Util/index.html
index 9d1f0bc3..9b97e601 100644
--- a/tiny_httpd/Tiny_httpd_core/Util/index.html
+++ b/tiny_httpd/Tiny_httpd_core/Util/index.html
@@ -1,2 +1,2 @@
-Util (tiny_httpd.Tiny_httpd_core.Util) Module Tiny_httpd_core.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.
val parse_query : string -> ((string * string) list, string) resultParse a query as a list of '&' or ';' separated key=value pairs. The order might not be preserved.
val show_sockaddr : Unix.sockaddr -> stringSimple printer for socket addresses.
+Util (tiny_httpd.Tiny_httpd_core.Util) Module Tiny_httpd_core.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.
val parse_query : string -> ((string * string) list, string) resultParse a query as a list of '&' or ';' separated key=value pairs. The order might not be preserved.
val show_sockaddr : Unix.sockaddr -> stringSimple printer for socket addresses.
diff --git a/tiny_httpd/_doc-dir/CHANGES.md b/tiny_httpd/_doc-dir/CHANGES.md
index 2f670075..fd440d18 100644
--- a/tiny_httpd/_doc-dir/CHANGES.md
+++ b/tiny_httpd/_doc-dir/CHANGES.md
@@ -1,6 +1,32 @@
## Pending
+## 0.17
+
+- add optional middlewares to tiny_httpd_ws
+- add `Head_middleware.trivial`
+- add `Head_middleware.t`; accept it for SSE/websocket
+- add `Request.pp_with` which is a customizable printer
+- expose `Response.Bad_req`
+- use `iostream` for IOs
+- add a `hmap`-typed field to requests, to carry request specific data
+ across middlewares
+- http_of_dir: ability to setup socket timeout
+- add `tiny_httpd.ws`, a websocket library
+- add `Response_code.is_success`
+
- fix: No setting of sigprocmask on Windows
+- fix: give the correct code+error if protocol upgrade fails
+- remove potentially security-leaking debug line
+- fix: avoid collisions in `Mime_` private module
+- fix middlewares: merge-sort per-request middleares and global ones
+- fix tiny_httpd dir: handle html files
+
+- perf: optim in read_line
+- perf: remove some uses of scanf in parsing
+
+- require iostream-camlzip >= 0.2.1
+- add optional dependency on `logs`
+- logs is a testdep for tiny_httpd_camlzip
## 0.16
diff --git a/tiny_httpd_camlzip/_doc-dir/CHANGES.md b/tiny_httpd_camlzip/_doc-dir/CHANGES.md
index 2f670075..fd440d18 100644
--- a/tiny_httpd_camlzip/_doc-dir/CHANGES.md
+++ b/tiny_httpd_camlzip/_doc-dir/CHANGES.md
@@ -1,6 +1,32 @@
## Pending
+## 0.17
+
+- add optional middlewares to tiny_httpd_ws
+- add `Head_middleware.trivial`
+- add `Head_middleware.t`; accept it for SSE/websocket
+- add `Request.pp_with` which is a customizable printer
+- expose `Response.Bad_req`
+- use `iostream` for IOs
+- add a `hmap`-typed field to requests, to carry request specific data
+ across middlewares
+- http_of_dir: ability to setup socket timeout
+- add `tiny_httpd.ws`, a websocket library
+- add `Response_code.is_success`
+
- fix: No setting of sigprocmask on Windows
+- fix: give the correct code+error if protocol upgrade fails
+- remove potentially security-leaking debug line
+- fix: avoid collisions in `Mime_` private module
+- fix middlewares: merge-sort per-request middleares and global ones
+- fix tiny_httpd dir: handle html files
+
+- perf: optim in read_line
+- perf: remove some uses of scanf in parsing
+
+- require iostream-camlzip >= 0.2.1
+- add optional dependency on `logs`
+- logs is a testdep for tiny_httpd_camlzip
## 0.16