From 572168967f8a8331a67205123f9b395b575ff29f Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 8 Aug 2023 14:41:58 -0400 Subject: [PATCH] remove last qtest --- src/Tiny_httpd_server.ml | 18 +----------------- tests/unit/dune | 2 +- tests/unit/t_server.ml | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 tests/unit/t_server.ml diff --git a/src/Tiny_httpd_server.ml b/src/Tiny_httpd_server.ml index 31ca7edf..17f5b364 100644 --- a/src/Tiny_httpd_server.ml +++ b/src/Tiny_httpd_server.ml @@ -349,22 +349,6 @@ module Request = struct end end -(*$R - let q = "GET hello HTTP/1.1\r\nHost: coucou\r\nContent-Length: 11\r\n\r\nsalutationsSOMEJUNK" in - let str = Tiny_httpd.Byte_stream.of_string q in - let r = Request.Internal_.parse_req_start ~get_time_s:(fun _ -> 0.) str in - match r with - | None -> assert_failure "should parse" - | Some req -> - assert_equal (Some "coucou") (Headers.get "Host" req.Request.headers); - assert_equal (Some "coucou") (Headers.get "host" req.Request.headers); - assert_equal (Some "11") (Headers.get "content-length" req.Request.headers); - assert_equal "hello" req.Request.path; - let req = Request.Internal_.parse_body req str |> Request.read_body_full in - assert_equal ~printer:(fun s->s) "salutations" req.Request.body; - () -*) - module Response = struct type body = [ `String of string @@ -967,7 +951,7 @@ module Unix_tcp_server_ = struct (try Unix.close client_sock with _ -> ()); Sem_.release 1 self.sem_max_connections; raise e); - ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ]); + ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ]) with e -> Sem_.release 1 self.sem_max_connections; _debug (fun k -> diff --git a/tests/unit/dune b/tests/unit/dune index 329becc8..c6944d20 100644 --- a/tests/unit/dune +++ b/tests/unit/dune @@ -1,5 +1,5 @@ (tests - (names t_util t_buf) + (names t_util t_buf t_server) (package tiny_httpd) (libraries tiny_httpd qcheck-core qcheck-core.runner test_util)) diff --git a/tests/unit/t_server.ml b/tests/unit/t_server.ml new file mode 100644 index 00000000..ef85e9be --- /dev/null +++ b/tests/unit/t_server.ml @@ -0,0 +1,23 @@ +open Test_util +open Tiny_httpd_server + +let () = + let q = + "GET hello HTTP/1.1\r\n\ + Host: coucou\r\n\ + Content-Length: 11\r\n\ + \r\n\ + salutationsSOMEJUNK" + in + let str = Tiny_httpd.Byte_stream.of_string q in + let r = Request.Internal_.parse_req_start ~get_time_s:(fun _ -> 0.) str in + match r with + | None -> failwith "should parse" + | Some req -> + assert_eq (Some "coucou") (Headers.get "Host" req.Request.headers); + assert_eq (Some "coucou") (Headers.get "host" req.Request.headers); + assert_eq (Some "11") (Headers.get "content-length" req.Request.headers); + assert_eq "hello" req.Request.path; + let req = Request.Internal_.parse_body req str |> Request.read_body_full in + assert_eq ~to_string:(fun s -> s) "salutations" req.Request.body; + ()