From 9eb3cbfc70d112d09eccada835667b76d1f758f6 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 20 Jun 2024 15:23:42 -0400 Subject: [PATCH] prepare for 0.17 --- CHANGES.md | 26 ++++++++++++++++++++++++++ dune-project | 2 +- src/core/request.mli | 10 +++++----- src/core/response.mli | 2 +- src/core/response_code.mli | 2 +- src/core/server.mli | 10 +++++----- src/core/util.mli | 4 ++-- tiny_httpd.opam | 2 +- tiny_httpd_camlzip.opam | 2 +- 9 files changed, 43 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2f670075..fd440d18 100644 --- a/CHANGES.md +++ b/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/dune-project b/dune-project index d03fd93a..f56ce53f 100644 --- a/dune-project +++ b/dune-project @@ -4,7 +4,7 @@ (authors c-cube) (maintainers c-cube) -(version 0.16) +(version 0.17) (source (github c-cube/tiny_httpd)) (homepage https://github.com/c-cube/tiny_httpd/) (license MIT) diff --git a/src/core/request.mli b/src/core/request.mli index e4242bcf..601d9615 100644 --- a/src/core/request.mli +++ b/src/core/request.mli @@ -11,7 +11,7 @@ type 'body t = private { (** Host header, mandatory. It can also be found in {!headers}. *) client_addr: Unix.sockaddr; (** Client address. Available since 0.14. *) headers: Headers.t; (** List of headers. *) - mutable meta: Hmap.t; (** Metadata. @since NEXT_RELEASE *) + mutable meta: Hmap.t; (** Metadata. @since 0.17 *) http_version: int * int; (** HTTP version. This should be either [1, 0] or [1, 1]. *) path: string; (** Full path of the requested URL. *) @@ -38,16 +38,16 @@ type 'body t = private { val add_meta : _ t -> 'a Hmap.key -> 'a -> unit (** Add metadata - @since NEXT_RELEASE *) + @since 0.17 *) val get_meta : _ t -> 'a Hmap.key -> 'a option (** Get metadata - @since NEXT_RELEASE *) + @since 0.17 *) val get_meta_exn : _ t -> 'a Hmap.key -> 'a (** Like {!get_meta} but can fail @raise Invalid_argument if not present - @since NEXT_RELEASE *) + @since 0.17 *) val pp_with : ?mask_header:(string -> bool) -> @@ -94,7 +94,7 @@ val set_header : string -> string -> 'a t -> 'a t val remove_header : string -> 'a t -> 'a t (** Remove one instance of this header. - @since NEXT_RELEASE *) + @since 0.17 *) val update_headers : (Headers.t -> Headers.t) -> 'a t -> 'a t (** Modify headers using the given function. diff --git a/src/core/response.mli b/src/core/response.mli index 4cf0f192..1586f301 100644 --- a/src/core/response.mli +++ b/src/core/response.mli @@ -38,7 +38,7 @@ val update_headers : (Headers.t -> Headers.t) -> t -> t val remove_header : string -> t -> t (** Remove one instance of this header. - @since NEXT_RELEASE *) + @since 0.17 *) val set_headers : Headers.t -> t -> t (** Set all headers. diff --git a/src/core/response_code.mli b/src/core/response_code.mli index fd0663d4..3755fcee 100644 --- a/src/core/response_code.mli +++ b/src/core/response_code.mli @@ -17,4 +17,4 @@ val descr : t -> string val is_success : t -> bool (** [is_success code] is true iff [code] is in the [2xx] or [3xx] range. - @since NEXT_RELEASE *) + @since 0.17 *) diff --git a/src/core/server.mli b/src/core/server.mli index 05ef6392..b585dfac 100644 --- a/src/core/server.mli +++ b/src/core/server.mli @@ -41,12 +41,12 @@ end These middlewares are simpler than full {!Middleware.t} and work in more contexts. - @since NEXT_RELEASE *) + @since 0.17 *) module Head_middleware : sig type t = { handle: 'a. 'a Request.t -> 'a Request.t } (** A handler that takes the request, without its body, and possibly modifies it. - @since NEXT_RELEASE *) + @since 0.17 *) val trivial : t (** Pass through *) @@ -260,10 +260,10 @@ val add_route_server_sent_handler : (** {2 Upgrade handlers} These handlers upgrade the connection to another protocol. - @since NEXT_RELEASE *) + @since 0.17 *) (** Handler that upgrades to another protocol. - @since NEXT_RELEASE *) + @since 0.17 *) module type UPGRADE_HANDLER = sig type handshake_state (** Some specific state returned after handshake *) @@ -287,7 +287,7 @@ module type UPGRADE_HANDLER = sig end type upgrade_handler = (module UPGRADE_HANDLER) -(** @since NEXT_RELEASE *) +(** @since 0.17 *) val add_upgrade_handler : ?accept:(unit Request.t -> (unit, Response_code.t * string) result) -> diff --git a/src/core/util.mli b/src/core/util.mli index 1e5a20f3..1971b5a5 100644 --- a/src/core/util.mli +++ b/src/core/util.mli @@ -37,8 +37,8 @@ val parse_query : string -> ((string * string) list, string) result val show_sockaddr : Unix.sockaddr -> string (** Simple printer for socket addresses. - @since NEXT_RELEASE *) + @since 0.17 *) val is_ipv6_str : string -> bool (** Is this string potentially an IPV6 address? - @since NEXT_RELEASE *) + @since 0.17 *) diff --git a/tiny_httpd.opam b/tiny_httpd.opam index c144b511..07d095bd 100644 --- a/tiny_httpd.opam +++ b/tiny_httpd.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.16" +version: "0.17" synopsis: "Minimal HTTP server using threads" maintainer: ["c-cube"] authors: ["c-cube"] diff --git a/tiny_httpd_camlzip.opam b/tiny_httpd_camlzip.opam index 469935b2..01453b61 100644 --- a/tiny_httpd_camlzip.opam +++ b/tiny_httpd_camlzip.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.16" +version: "0.17" synopsis: "Interface to camlzip for tiny_httpd" maintainer: ["c-cube"] authors: ["c-cube"]