Skip to content

Commit ac1c1ab

Browse files
committed
prepare for 0.14
1 parent d08fe69 commit ac1c1ab

10 files changed

+43
-23
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2+
## 0.14
3+
4+
- breaking: `set_top_handler` takes a stream request, for more generality
5+
6+
- Don't let client handling threads handle SIGINT/SIGHUP
7+
- improve termination behavior (wait for threads to terminate when shutting down server)
8+
- Preserve client address down to Request.t
9+
- add `Tiny_httpd_io` module, abstraction over IOs (output/input) as better IO channels
10+
than the stdlib's
11+
- add `Tiny_httpd_html.to_writer`
12+
- add `IO.Writer.t`, a push based stream.
13+
- add `Server.run_exn`
14+
- add `Tiny_httpd_pool`
15+
- server: add `IO_BACKEND` abstraction; implement a unix version of it
16+
17+
- perf: use TCP_NODELAY for client sockets
18+
- perf: use a resource pool to recycle buffers, improves memory consumption and GC pressure
19+
120
## 0.13
221

322
- feat: `Server.run` takes `?after_init` parameter

dune-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
(lang dune 2.0)
2+
(name tiny_httpd)

src/Tiny_httpd_buf.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ val contents_and_clear : t -> string
2323

2424
val add_char : t -> char -> unit
2525
(** Add a single char.
26-
@since NEXT_RELEASE *)
26+
@since 0.14 *)
2727

2828
val add_bytes : t -> bytes -> int -> int -> unit
2929
(** Append given bytes slice to the buffer.
3030
@since 0.5 *)
3131

3232
val add_string : t -> string -> unit
3333
(** Add string.
34-
@since NEXT_RELEASE *)
34+
@since 0.14 *)
3535

3636
val add_buffer : t -> Buffer.t -> unit
3737
(** Append bytes from buffer.
38-
@since NEXT_RELEASE *)
38+
@since 0.14 *)

src/Tiny_httpd_html.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include Tiny_httpd_html_
1414
(** Write an HTML element to this output.
1515
@param top if true, add DOCTYPE at the beginning. The top element should then
1616
be a "html" tag.
17-
@since NEXT_RELEASE
17+
@since 0.14
1818
*)
1919
let to_output ?(top = false) (self : elt) (out : IO.Output.t) : unit =
2020
let out = Out.create_of_out out in
@@ -49,12 +49,12 @@ let to_string_l (l : elt list) =
4949
let to_string_top = to_string ~top:true
5050

5151
(** Write a toplevel element to an output channel.
52-
@since NEXT_RELEASE *)
52+
@since 0.14 *)
5353
let to_out_channel_top = to_output ~top:true
5454

5555
(** Produce a streaming writer from this HTML element.
5656
@param top if true, add a DOCTYPE. See {!to_out_channel}.
57-
@since NEXT_RELEASE *)
57+
@since 0.14 *)
5858
let to_writer ?top (self : elt) : IO.Writer.t =
5959
let write oc = to_output ?top self oc in
6060
IO.Writer.make ~write ()

src/Tiny_httpd_io.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
{b NOTE}: experimental.
77
8-
@since NEXT_RELEASE
8+
@since 0.14
99
*)
1010

1111
module Buf = Tiny_httpd_buf
@@ -167,7 +167,7 @@ module Writer = struct
167167
This is useful for responses: an http endpoint can return a writer
168168
as its response's body, and output into it as if it were a regular
169169
[out_channel], including controlling calls to [flush].
170-
@since NEXT_RELEASE
170+
@since 0.14
171171
*)
172172

173173
let[@inline] make ~write () : t = { write }

src/Tiny_httpd_pool.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
cheap to produce and discard, and will never block waiting for
66
a resource — it's not a good pool for DB connections.
77
8-
@since NEXT_RELEASE. *)
8+
@since 0.14. *)
99

1010
type 'a t
1111
(** Pool of values of type ['a] *)

src/Tiny_httpd_server.mli

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module Request : sig
6868
host: string;
6969
(** Host header, mandatory. It can also be found in {!headers}. *)
7070
client_addr: Unix.sockaddr;
71-
(** Client address. Available since NEXT_RELEASE. *)
71+
(** Client address. Available since 0.14. *)
7272
headers: Headers.t; (** List of headers. *)
7373
http_version: int * int;
7474
(** HTTP version. This should be either [1, 0] or [1, 1]. *)
@@ -155,7 +155,7 @@ module Request : sig
155155
(** Read the whole body into a string. Potentially blocking.
156156
157157
@param buf_size initial size of underlying buffer (since 0.11)
158-
@param buf the initial buffer (since NEXT_RELEASE)
158+
@param buf the initial buffer (since 0.14)
159159
*)
160160

161161
(**/**)
@@ -213,7 +213,7 @@ module Response : sig
213213
- [`Void] replies with no body.
214214
- [`Writer w] replies with a body created by the writer [w], using
215215
a chunked encoding.
216-
It is available since NEXT_RELEASE.
216+
It is available since 0.14.
217217
*)
218218

219219
type t = private {
@@ -477,7 +477,7 @@ val create_from :
477477
@param buf_size size for buffers (since 0.11)
478478
@param middlewares see {!add_middleware} for more details.
479479
480-
@since NEXT_RELEASE
480+
@since 0.14
481481
*)
482482

483483
val addr : t -> string
@@ -540,7 +540,7 @@ val set_top_handler : t -> (byte_stream Request.t -> Response.t) -> unit
540540
If no top handler is installed, unhandled paths will return a [404] not found
541541
542542
This used to take a [string Request.t] but it now takes a [byte_stream Request.t]
543-
since NEXT_RELEASE . Use {!Request.read_body_full} to read the body into
543+
since 0.14 . Use {!Request.read_body_full} to read the body into
544544
a string if needed.
545545
*)
546546

@@ -642,7 +642,7 @@ val add_route_server_sent_handler :
642642

643643
val running : t -> bool
644644
(** Is the server running?
645-
@since NEXT_RELEASE *)
645+
@since 0.14 *)
646646

647647
val stop : t -> unit
648648
(** Ask the server to stop. This might not have an immediate effect
@@ -662,7 +662,7 @@ val run : ?after_init:(unit -> unit) -> t -> (unit, exn) result
662662
val run_exn : ?after_init:(unit -> unit) -> t -> unit
663663
(** [run_exn s] is like [run s] but re-raises an exception if the server exits
664664
with an error.
665-
@since NEXT_RELEASE *)
665+
@since 0.14 *)
666666

667667
(**/**)
668668

src/Tiny_httpd_stream.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ val empty : t
6666

6767
val of_input : ?buf_size:int -> Tiny_httpd_io.Input.t -> t
6868
(** Make a buffered stream from the given channel.
69-
@since NEXT_RELEASE *)
69+
@since 0.14 *)
7070

7171
val of_chan : ?buf_size:int -> in_channel -> t
7272
(** Make a buffered stream from the given channel. *)
@@ -96,11 +96,11 @@ val to_chan : out_channel -> t -> unit
9696

9797
val to_chan' : Tiny_httpd_io.Output.t -> t -> unit
9898
(** Write to the IO channel.
99-
@since NEXT_RELEASE *)
99+
@since 0.14 *)
100100

101101
val to_writer : t -> Tiny_httpd_io.Writer.t
102102
(** Turn this stream into a writer.
103-
@since NEXT_RELEASE *)
103+
@since 0.14 *)
104104

105105
val make :
106106
?bs:bytes ->
@@ -151,9 +151,9 @@ val read_exactly :
151151

152152
val output_chunked : ?buf:Tiny_httpd_buf.t -> out_channel -> t -> unit
153153
(** Write the stream into the channel, using the chunked encoding.
154-
@param buf optional buffer for chunking (since NEXT_RELEASE) *)
154+
@param buf optional buffer for chunking (since 0.14) *)
155155

156156
val output_chunked' :
157157
?buf:Tiny_httpd_buf.t -> Tiny_httpd_io.Output.t -> t -> unit
158158
(** Write the stream into the channel, using the chunked encoding.
159-
@since NEXT_RELEASE *)
159+
@since 0.14 *)

tiny_httpd.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
opam-version: "2.0"
2-
version: "0.13"
2+
version: "0.14"
33
authors: ["Simon Cruanes"]
44
maintainer: "[email protected]"
55
license: "MIT"

tiny_httpd_camlzip.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
opam-version: "2.0"
2-
version: "0.13"
2+
version: "0.14"
33
authors: ["Simon Cruanes"]
44
maintainer: "[email protected]"
55
license: "MIT"

0 commit comments

Comments
 (0)