mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
remove last qtest
This commit is contained in:
parent
b36ea35703
commit
572168967f
3 changed files with 25 additions and 18 deletions
|
|
@ -349,22 +349,6 @@ module Request = struct
|
||||||
end
|
end
|
||||||
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
|
module Response = struct
|
||||||
type body =
|
type body =
|
||||||
[ `String of string
|
[ `String of string
|
||||||
|
|
@ -967,7 +951,7 @@ module Unix_tcp_server_ = struct
|
||||||
(try Unix.close client_sock with _ -> ());
|
(try Unix.close client_sock with _ -> ());
|
||||||
Sem_.release 1 self.sem_max_connections;
|
Sem_.release 1 self.sem_max_connections;
|
||||||
raise e);
|
raise e);
|
||||||
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ]);
|
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
||||||
with e ->
|
with e ->
|
||||||
Sem_.release 1 self.sem_max_connections;
|
Sem_.release 1 self.sem_max_connections;
|
||||||
_debug (fun k ->
|
_debug (fun k ->
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(tests
|
(tests
|
||||||
(names t_util t_buf)
|
(names t_util t_buf t_server)
|
||||||
(package tiny_httpd)
|
(package tiny_httpd)
|
||||||
(libraries tiny_httpd qcheck-core qcheck-core.runner test_util))
|
(libraries tiny_httpd qcheck-core qcheck-core.runner test_util))
|
||||||
|
|
|
||||||
23
tests/unit/t_server.ml
Normal file
23
tests/unit/t_server.ml
Normal file
|
|
@ -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;
|
||||||
|
()
|
||||||
Loading…
Add table
Reference in a new issue