-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
help wantedExtra attention is neededExtra attention is neededhttp_of_dirrelated to the binary for serving a local directoryrelated to the binary for serving a local directory
Description
Hi, I am trying to programmically create and serve a local directory via http using this library as a way to unit test an http client. However when I call Tiny_httpd.run_exn dune runtest freezes. Is there a way I can call run_exn as background task so that the program can continue to use the http server to perform unit tests? Here is what I wrote:
let dir_behavior = Tiny_httpd.Dir.Lists
and download = true and delete = true and upload = true in
let config = Tiny_httpd.Dir.config ~dir_behavior ~delete ~upload ~download ()
and addr = "127.0.0.1" and port = 8080 and timeout = 30000. in
let server = Tiny_httpd.create ~max_connections:4 ~addr ~port ~timeout () in
and suffix = (string_of_int @@ Random.int 5000) ^ ".zarr" in
let dir = Filename.(concat (get_temp_dir_name ()) (rand_num ^ ".zarr")) in
Tiny_httpd_unix.Dir.add_dir_path ~config ~dir ~prefix:"" server;
Tiny_httpd.run_exn ~after_init:(fun () ->
perform_unit_tests_for_client;
Tiny_httpd.stop server) server
If I use http_of_dir <dir_name> -p 8080 in another shell session the client unit tests run just fine. Am I using this library's serving capabilities incorrectly? How can I achieve what i'm looking for?
As an aside it appears POST/PUT methods don't actually create a resource under the directory even after the client (it uses Ezcurl internally) returns a 200/201 status code.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededhttp_of_dirrelated to the binary for serving a local directoryrelated to the binary for serving a local directory