Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove various [open Cohttp] #1058

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading