From 52eb318ad582a212ea24e0751534de9019052d16 Mon Sep 17 00:00:00 2001 From: Doug Patti Date: Sat, 3 Apr 2021 19:13:14 -0400 Subject: [PATCH] test-response-before-read: read body in a loop `schedule_read` only handles the first chunk, we need to re-schedule for each successive chunk. --- lib_test/test_server_connection.ml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_test/test_server_connection.ml b/lib_test/test_server_connection.ml index 62869586..c5e9a52d 100644 --- a/lib_test/test_server_connection.ml +++ b/lib_test/test_server_connection.ml @@ -858,11 +858,15 @@ let test_response_finished_before_body_read () = let response = Response.create `OK ~headers:(Headers.encoding_fixed 4) in let rev_body_chunks = ref [] in let request_handler reqd = - Body.schedule_read - (Reqd.request_body reqd) - ~on_read:(fun buf ~off ~len -> - rev_body_chunks := Bigstringaf.substring buf ~off ~len :: !rev_body_chunks) - ~on_eof:ignore; + let rec read_body () = + Body.schedule_read + (Reqd.request_body reqd) + ~on_read:(fun buf ~off ~len -> + rev_body_chunks := Bigstringaf.substring buf ~off ~len :: !rev_body_chunks; + read_body ()) + ~on_eof:ignore; + in + read_body (); Reqd.respond_with_string reqd response "done" in let t = create request_handler in