Skip to content

Commit

Permalink
add test for queue mechanics
Browse files Browse the repository at this point in the history
This tests a specific situation where multiple requests are queued, but
the server wants to close the connection after the first.
  • Loading branch information
dpatti committed Apr 3, 2021
1 parent 52eb318 commit cfa3085
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib_test/test_server_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,23 @@ let test_multiple_async_requests_in_single_read () =
reader_ready t;
;;

let test_multiple_requests_in_single_read_with_close () =
let reqs_handled = ref 0 in
let t =
create (fun reqd ->
reqs_handled := !reqs_handled + 1;
let response = Response.create `OK ~headers:Headers.connection_close in
Reqd.respond_with_string reqd response "")
in
let reqs =
request_to_string (Request.create `GET "/") ^
request_to_string (Request.create `GET "/")
in
read_string t reqs;
reader_closed t;
Alcotest.(check int) "fired handler of first requests" 1 !reqs_handled
;;

let test_parse_failure_after_checkpoint () =
let error_queue = ref None in
let error_handler ?request:_ error _start_response =
Expand Down Expand Up @@ -905,6 +922,7 @@ let tests =
; "bad request", `Quick, test_bad_request
; "multiple requests in single read", `Quick, test_multiple_requests_in_single_read
; "multiple async requests in single read", `Quick, test_multiple_async_requests_in_single_read
; "multiple requests with connection close", `Quick, test_multiple_requests_in_single_read_with_close
; "parse failure after checkpoint", `Quick, test_parse_failure_after_checkpoint
; "response finished before body read", `Quick, test_response_finished_before_body_read
]

0 comments on commit cfa3085

Please sign in to comment.