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 e8e8f89
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib_test/test_server_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,20 @@ let test_multiple_async_requests_in_single_read () =
reader_ready t;
;;

let test_multiple_requests_in_single_read_with_close () =
let response = Response.create `OK ~headers:Headers.connection_close in
let t =
create (fun reqd -> 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;
write_response t response;
connection_is_shutdown t;
;;

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 +919,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 e8e8f89

Please sign in to comment.