Skip to content

Commit

Permalink
cohttp-lwt-unix: fix test_sanity.exe
Browse files Browse the repository at this point in the history
In the absence of an encoding in the headers,
Http.Response.Make now defaults to Unknown,
which makes the system hang unable to decide
how to get the body.

Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
  • Loading branch information
mseri committed Jun 14, 2022
1 parent e89bd22 commit 106ccc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cohttp-lwt-unix/test/test_sanity.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ let server =
(fun _ _ ->
Lwt.return
(`Expert
( Http.Response.make (),
fun _ic oc -> Lwt_io.write oc "8\r\nexpert 1\r\n0\r\n\r\n" )));
(let headers =
Http.(
Header.add_transfer_encoding (Header.init ()) Transfer.Chunked)
in
( Http.Response.make ~headers (),
fun _ic oc -> Lwt_io.write oc "8\r\nexpert 1\r\n0\r\n\r\n" ))));
(fun _ _ ->
Lwt.return
(`Expert
( Http.Response.make (),
( (* Alternatively, cohttp.response.make injects the Chunked encoding when no
encoding is already in the headers. *)
Cohttp.Response.make (),
fun ic oc ->
Lwt_io.write oc "8\r\nexpert 2\r\n0\r\n\r\n" >>= fun () ->
Lwt_io.flush oc >>= fun () ->
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt-unix/test/test_sanity_noisy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Body = Cohttp_lwt.Body
module IO = Cohttp_lwt_unix.Private.IO

let chunk_body = [ "one"; ""; " "; "bar"; "" ]
let () = Logs.set_level (Some Info)
let () = Logs.set_level (Some Warning)
let () = Logs.set_reporter Logs.nop_reporter

let check_logs test () =
Expand Down

0 comments on commit 106ccc8

Please sign in to comment.