mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
prepare for 0.14
This commit is contained in:
parent
d08fe6926d
commit
ac1c1ab502
10 changed files with 43 additions and 23 deletions
19
CHANGES.md
19
CHANGES.md
|
|
@ -1,3 +1,22 @@
|
|||
|
||||
## 0.14
|
||||
|
||||
- breaking: `set_top_handler` takes a stream request, for more generality
|
||||
|
||||
- Don't let client handling threads handle SIGINT/SIGHUP
|
||||
- improve termination behavior (wait for threads to terminate when shutting down server)
|
||||
- Preserve client address down to Request.t
|
||||
- add `Tiny_httpd_io` module, abstraction over IOs (output/input) as better IO channels
|
||||
than the stdlib's
|
||||
- add `Tiny_httpd_html.to_writer`
|
||||
- add `IO.Writer.t`, a push based stream.
|
||||
- add `Server.run_exn`
|
||||
- add `Tiny_httpd_pool`
|
||||
- server: add `IO_BACKEND` abstraction; implement a unix version of it
|
||||
|
||||
- perf: use TCP_NODELAY for client sockets
|
||||
- perf: use a resource pool to recycle buffers, improves memory consumption and GC pressure
|
||||
|
||||
## 0.13
|
||||
|
||||
- feat: `Server.run` takes `?after_init` parameter
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
(lang dune 2.0)
|
||||
(name tiny_httpd)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ val contents_and_clear : t -> string
|
|||
|
||||
val add_char : t -> char -> unit
|
||||
(** Add a single char.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val add_bytes : t -> bytes -> int -> int -> unit
|
||||
(** Append given bytes slice to the buffer.
|
||||
|
|
@ -31,8 +31,8 @@ val add_bytes : t -> bytes -> int -> int -> unit
|
|||
|
||||
val add_string : t -> string -> unit
|
||||
(** Add string.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val add_buffer : t -> Buffer.t -> unit
|
||||
(** Append bytes from buffer.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ include Tiny_httpd_html_
|
|||
(** Write an HTML element to this output.
|
||||
@param top if true, add DOCTYPE at the beginning. The top element should then
|
||||
be a "html" tag.
|
||||
@since NEXT_RELEASE
|
||||
@since 0.14
|
||||
*)
|
||||
let to_output ?(top = false) (self : elt) (out : IO.Output.t) : unit =
|
||||
let out = Out.create_of_out out in
|
||||
|
|
@ -49,12 +49,12 @@ let to_string_l (l : elt list) =
|
|||
let to_string_top = to_string ~top:true
|
||||
|
||||
(** Write a toplevel element to an output channel.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
let to_out_channel_top = to_output ~top:true
|
||||
|
||||
(** Produce a streaming writer from this HTML element.
|
||||
@param top if true, add a DOCTYPE. See {!to_out_channel}.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
let to_writer ?top (self : elt) : IO.Writer.t =
|
||||
let write oc = to_output ?top self oc in
|
||||
IO.Writer.make ~write ()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
{b NOTE}: experimental.
|
||||
|
||||
@since NEXT_RELEASE
|
||||
@since 0.14
|
||||
*)
|
||||
|
||||
module Buf = Tiny_httpd_buf
|
||||
|
|
@ -167,7 +167,7 @@ module Writer = struct
|
|||
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].
|
||||
@since NEXT_RELEASE
|
||||
@since 0.14
|
||||
*)
|
||||
|
||||
let[@inline] make ~write () : t = { write }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
cheap to produce and discard, and will never block waiting for
|
||||
a resource — it's not a good pool for DB connections.
|
||||
|
||||
@since NEXT_RELEASE. *)
|
||||
@since 0.14. *)
|
||||
|
||||
type 'a t
|
||||
(** Pool of values of type ['a] *)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ module Request : sig
|
|||
host: string;
|
||||
(** Host header, mandatory. It can also be found in {!headers}. *)
|
||||
client_addr: Unix.sockaddr;
|
||||
(** Client address. Available since NEXT_RELEASE. *)
|
||||
(** 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]. *)
|
||||
|
|
@ -155,7 +155,7 @@ module Request : sig
|
|||
(** Read the whole body into a string. Potentially blocking.
|
||||
|
||||
@param buf_size initial size of underlying buffer (since 0.11)
|
||||
@param buf the initial buffer (since NEXT_RELEASE)
|
||||
@param buf the initial buffer (since 0.14)
|
||||
*)
|
||||
|
||||
(**/**)
|
||||
|
|
@ -213,7 +213,7 @@ module Response : sig
|
|||
- [`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.
|
||||
It is available since 0.14.
|
||||
*)
|
||||
|
||||
type t = private {
|
||||
|
|
@ -477,7 +477,7 @@ val create_from :
|
|||
@param buf_size size for buffers (since 0.11)
|
||||
@param middlewares see {!add_middleware} for more details.
|
||||
|
||||
@since NEXT_RELEASE
|
||||
@since 0.14
|
||||
*)
|
||||
|
||||
val addr : t -> string
|
||||
|
|
@ -540,7 +540,7 @@ val set_top_handler : t -> (byte_stream Request.t -> Response.t) -> unit
|
|||
If no top handler is installed, unhandled paths will return a [404] not found
|
||||
|
||||
This used to take a [string Request.t] but it now takes a [byte_stream Request.t]
|
||||
since NEXT_RELEASE . Use {!Request.read_body_full} to read the body into
|
||||
since 0.14 . Use {!Request.read_body_full} to read the body into
|
||||
a string if needed.
|
||||
*)
|
||||
|
||||
|
|
@ -642,7 +642,7 @@ val add_route_server_sent_handler :
|
|||
|
||||
val running : t -> bool
|
||||
(** Is the server running?
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val stop : t -> unit
|
||||
(** 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
|
|||
val run_exn : ?after_init:(unit -> unit) -> t -> unit
|
||||
(** [run_exn s] is like [run s] but re-raises an exception if the server exits
|
||||
with an error.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
(**/**)
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ val empty : t
|
|||
|
||||
val of_input : ?buf_size:int -> Tiny_httpd_io.Input.t -> t
|
||||
(** Make a buffered stream from the given channel.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val of_chan : ?buf_size:int -> in_channel -> t
|
||||
(** Make a buffered stream from the given channel. *)
|
||||
|
|
@ -96,11 +96,11 @@ val to_chan : out_channel -> t -> unit
|
|||
|
||||
val to_chan' : Tiny_httpd_io.Output.t -> t -> unit
|
||||
(** Write to the IO channel.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val to_writer : t -> Tiny_httpd_io.Writer.t
|
||||
(** Turn this stream into a writer.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
||||
val make :
|
||||
?bs:bytes ->
|
||||
|
|
@ -151,9 +151,9 @@ val read_exactly :
|
|||
|
||||
val output_chunked : ?buf:Tiny_httpd_buf.t -> out_channel -> t -> unit
|
||||
(** Write the stream into the channel, using the chunked encoding.
|
||||
@param buf optional buffer for chunking (since NEXT_RELEASE) *)
|
||||
@param buf optional buffer for chunking (since 0.14) *)
|
||||
|
||||
val output_chunked' :
|
||||
?buf:Tiny_httpd_buf.t -> Tiny_httpd_io.Output.t -> t -> unit
|
||||
(** Write the stream into the channel, using the chunked encoding.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 0.14 *)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
opam-version: "2.0"
|
||||
version: "0.13"
|
||||
version: "0.14"
|
||||
authors: ["Simon Cruanes"]
|
||||
maintainer: "simon.cruanes.2007@m4x.org"
|
||||
license: "MIT"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
opam-version: "2.0"
|
||||
version: "0.13"
|
||||
version: "0.14"
|
||||
authors: ["Simon Cruanes"]
|
||||
maintainer: "simon.cruanes.2007@m4x.org"
|
||||
license: "MIT"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue