Skip to content

Commit

Permalink
refactor: simplify flush writer
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 391bec85-4b37-4893-a1f4-7961b403d153 -->
  • Loading branch information
rgrinberg committed Jun 30, 2024
1 parent 63c665b commit 366a50b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions cohttp/src/transfer_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,15 @@ module Make (IO : S.IO) = struct
if String.length s = 0 then return () else writer io s

let make_writer ~flush mode =
let write =
match mode with
| Chunked -> Chunked.write
| Fixed _ -> Fixed.write
| Unknown -> Unknown.write
in
match flush with
| false -> (
match mode with
| Chunked -> Chunked.write
| Fixed _ -> Fixed.write
| Unknown -> Unknown.write)
| true ->
(match mode with
| Chunked -> write_and_flush Chunked.write
| Fixed _ -> write_and_flush Fixed.write
| Unknown -> write_and_flush Unknown.write)
|> write_ignore_blank
| false -> write
| true -> write_and_flush write |> write_ignore_blank

let read reader = reader ()
let write writer buf = writer buf
Expand Down

0 comments on commit 366a50b

Please sign in to comment.