mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
deprecate, add todos
This commit is contained in:
parent
6b0000eb6e
commit
8655200bd7
2 changed files with 6 additions and 2 deletions
|
|
@ -507,6 +507,7 @@ val active_connections : t -> int
|
||||||
val add_decode_request_cb :
|
val add_decode_request_cb :
|
||||||
t ->
|
t ->
|
||||||
(unit Request.t -> (unit Request.t * (byte_stream -> byte_stream)) option) -> unit
|
(unit Request.t -> (unit Request.t * (byte_stream -> byte_stream)) option) -> unit
|
||||||
|
[@@deprecated "use add_middleware"]
|
||||||
(** Add a callback for every request.
|
(** Add a callback for every request.
|
||||||
The callback can provide a stream transformer and a new request (with
|
The callback can provide a stream transformer and a new request (with
|
||||||
modified headers, typically).
|
modified headers, typically).
|
||||||
|
|
@ -518,6 +519,7 @@ val add_decode_request_cb :
|
||||||
|
|
||||||
val add_encode_response_cb:
|
val add_encode_response_cb:
|
||||||
t -> (unit Request.t -> Response.t -> Response.t option) -> unit
|
t -> (unit Request.t -> Response.t -> Response.t option) -> unit
|
||||||
|
[@@deprecated "use add_middleware"]
|
||||||
(** Add a callback for every request/response pair.
|
(** Add a callback for every request/response pair.
|
||||||
Similarly to {!add_encode_response_cb} the callback can return a new
|
Similarly to {!add_encode_response_cb} the callback can return a new
|
||||||
response, for example to compress it.
|
response, for example to compress it.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
module S = Tiny_httpd
|
module S = Tiny_httpd
|
||||||
module BS = Tiny_httpd.Byte_stream
|
module BS = Tiny_httpd.Byte_stream
|
||||||
|
|
||||||
let mk_decode_deflate_stream_ ~buf_size () (is:S.byte_stream) : S.byte_stream =
|
let decode_deflate_stream_ ~buf_size () (is:S.byte_stream) : S.byte_stream =
|
||||||
S._debug (fun k->k "wrap stream with deflate.decode");
|
S._debug (fun k->k "wrap stream with deflate.decode");
|
||||||
let buf = Bytes.make buf_size ' ' in
|
let buf = Bytes.make buf_size ' ' in
|
||||||
let buf_len = ref 0 in
|
let buf_len = ref 0 in
|
||||||
|
|
@ -156,7 +156,7 @@ let cb_decode_compressed_stream ~buf_size (req:unit S.Request.t) : _ option =
|
||||||
begin match Scanf.sscanf s "deflate, %s" (fun s -> s) with
|
begin match Scanf.sscanf s "deflate, %s" (fun s -> s) with
|
||||||
| tr' ->
|
| tr' ->
|
||||||
let req' = S.Request.set_header req "Transfer-Encoding" tr' in
|
let req' = S.Request.set_header req "Transfer-Encoding" tr' in
|
||||||
Some (req', mk_decode_deflate_stream_ ~buf_size ())
|
Some (req', decode_deflate_stream_ ~buf_size ())
|
||||||
| exception _ -> None
|
| exception _ -> None
|
||||||
end
|
end
|
||||||
| _ -> None
|
| _ -> None
|
||||||
|
|
@ -192,6 +192,8 @@ let cb_encode_compressed_stream
|
||||||
| `String _ | `Void -> None
|
| `String _ | `Void -> None
|
||||||
) else None
|
) else None
|
||||||
|
|
||||||
|
(* TODO: as middleware *)
|
||||||
|
|
||||||
let setup
|
let setup
|
||||||
?(compress_above=500*1024)
|
?(compress_above=500*1024)
|
||||||
?(buf_size=48 * 1_024) (server:S.t) : unit =
|
?(buf_size=48 * 1_024) (server:S.t) : unit =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue