Skip to content

Commit

Permalink
refactor: remove various [open Cohttp]
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 30ca24e6-0388-49ed-a76f-1638ef3abea7 -->
  • Loading branch information
rgrinberg committed Jun 30, 2024
1 parent f66a84d commit 5148bf8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cohttp-async/src/body.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ let write_body write_body (body : t) writer =
| `Pipe p -> Pipe.iter p ~f:(write_body writer)

let pipe_of_body read_chunk ic =
let open Cohttp.Transfer in
Pipe.create_reader ~close_on_exception:false (fun writer ->
Deferred.repeat_until_finished () (fun () ->
read_chunk ic >>= function
| Chunk buf ->
| Cohttp.Transfer.Chunk buf ->
(* Even if [writer] has been closed, the loop must continue reading
* from the input channel to ensure that it is left in a proper state
* for the next request to be processed (in the case of keep-alive).
Expand Down
3 changes: 1 addition & 2 deletions cohttp-async/src/body.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open! Base
open! Async_kernel
open! Cohttp

type t = [ Cohttp.Body.t | `Pipe of string Pipe.Reader.t ] [@@deriving sexp_of]

Expand All @@ -21,7 +20,7 @@ module Private : sig
('a -> string -> unit Deferred.t) -> t -> 'a -> unit Deferred.t

val pipe_of_body :
('a -> Transfer.chunk Deferred.t) -> 'a -> string Pipe.Reader.t
('a -> Cohttp.Transfer.chunk Deferred.t) -> 'a -> string Pipe.Reader.t

val disable_chunked_encoding : t -> (t * int64) Deferred.t
val drain : t -> unit Deferred.t
Expand Down
2 changes: 1 addition & 1 deletion cohttp-bench/lwt_unix_server.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Cohttp_lwt_unix
module Server = Cohttp_lwt_unix.Server

let length = 2053
let text = String.make length 'a'
Expand Down
7 changes: 4 additions & 3 deletions cohttp-lwt/src/body.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
*
}}}*)

open Cohttp
module Body = Cohttp.Body
module Transfer = Cohttp.Transfer
open Lwt

type t = [ Body.t | `Stream of (string Lwt_stream.t[@sexp.opaque]) ]
Expand All @@ -30,10 +31,10 @@ let create_stream fn arg =
| false -> (
fn arg >>= function
| Transfer.Done -> return_none
| Transfer.Final_chunk c ->
| Final_chunk c ->
fin := true;
return (Some c)
| Transfer.Chunk c -> return (Some c)))
| Chunk c -> return (Some c)))

let is_empty (body : t) =
match body with
Expand Down

0 comments on commit 5148bf8

Please sign in to comment.