Skip to content

Commit

Permalink
Add a test for persistent connection + empty fixed body (inhabitedtyp…
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored May 14, 2020
1 parent 7e8808a commit abc2b60
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Unreleased
- httpaf-async: Use [gluten](https://github.com/anmonteiro/gluten) to implement
the Async runtimes ([#69](https://github.com/anmonteiro/httpaf/pull/69))

httpaf (upstream) 0.6.5
httpaf (upstream) 0.6.6
--------------

- Initial fork point
[7de2d4ea](https://github.com/anmonteiro/httpaf/commit/7de2d4ea3bd09984d398854460a2d4c8a8e42127)
[7de2d4ea](https://github.com/anmonteiro/httpaf/commit/6aefc835552010ce8f8466c8695a7b106b49ec35)
31 changes: 31 additions & 0 deletions lib_test/test_client_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,36 @@ let test_fixed_body_persistent_connection () =
writer_yielded t;
;;

let test_empty_fixed_body_persistent_connection () =
let request' = Request.create
~headers:(Headers.of_list ["Content-Length", "0"])
`GET "/"
in
let response_handler response response_body =
Alcotest.(check (list (pair string string)))
"got expected headers"
[]
(Headers.to_rev_list response.Response.headers);
Body.close_reader response_body
in
let t = create ?config:None in
let body =
request
t
request'
~response_handler:response_handler
~error_handler:no_error_handler
in
write_request t request';
writer_yielded t;
Body.close_writer body;
reader_ready t;
read_response t (Response.create ~headers:(Headers.of_list []) `OK);
reader_ready t;
writer_yielded t;
;;


let test_client_upgrade () =
let writer_woken_up = ref false in
let reader_woken_up = ref false in
Expand Down Expand Up @@ -1050,6 +1080,7 @@ let tests =
; "Persistent connections, read response body", `Quick, test_persistent_connection_requests_body
; "Partial input", `Quick, test_partial_input
; "Empty fixed body shuts down writer", `Quick, test_empty_fixed_body
; "Empty fixed body in a persistent connection doesn't shut down the writer", `Quick, test_empty_fixed_body_persistent_connection
; "Fixed body shuts down writer if connection is not persistent", `Quick, test_fixed_body
; "Fixed body doesn't shut down the writer if connection is persistent",`Quick, test_fixed_body_persistent_connection
; "Client support for upgrading a connection", `Quick, test_client_upgrade
Expand Down

0 comments on commit abc2b60

Please sign in to comment.