From bbe8d1c5047d3334f83441807f6117b601134be1 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 27 May 2020 21:40:20 -0400 Subject: [PATCH] refactor(echo): simplify code, use gzip aggressively --- src/examples/echo.ml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/examples/echo.ml b/src/examples/echo.ml index a2920662..3b7c7700 100644 --- a/src/examples/echo.ml +++ b/src/examples/echo.ml @@ -11,18 +11,14 @@ let () = "-j", Arg.Set_int j, " maximum number of connections"; ]) (fun _ -> raise (Arg.Bad "")) "echo [option]*"; let server = S.create ~port:!port_ ~max_connections:!j () in - Tiny_httpd_camlzip.setup server; + Tiny_httpd_camlzip.setup ~compress_above:1024 ~buf_size:(1024*1024) server; (* say hello *) S.add_route_handler ~meth:`GET server S.Route.(exact "hello" @/ string @/ return) (fun name _req -> S.Response.make_string (Ok ("hello " ^name ^"!\n"))); S.add_route_handler ~meth:`GET server - S.Route.(exact "zcat" @/ string @/ return) + S.Route.(exact "zcat" @/ string_urlencoded @/ return) (fun path _req -> - let path = match Tiny_httpd_util.percent_decode path with - | Some s -> s - | None -> S.Response.fail_raise ~code:404 "invalid path %S" path - in let ic = open_in path in let str = S.Byte_stream.of_chan ic in let mime_type =