From b1898dbefee55d35aa161e6fc620d090e08dccf3 Mon Sep 17 00:00:00 2001 From: Marcello Seri Date: Tue, 31 Oct 2023 10:19:27 +0100 Subject: [PATCH 1/2] cohttp: move new client and server modules into a generic module to avoid shadowing Client and Server modules when opening Cohttp. This preserves backward compatibility for a very small price and improves library ergonomics since right now many project tend to open Cohttp to have the Headers and Response modules directly accessible. Signed-off-by: Marcello Seri --- cohttp-eio/src/client.ml | 2 +- cohttp-eio/src/client.mli | 2 +- cohttp-eio/src/server.mli | 2 +- cohttp-lwt.opam | 2 +- cohttp-lwt/src/client.ml | 2 +- cohttp-lwt/src/s.ml | 4 ++-- cohttp/src/cohttp.ml | 7 +++++-- dune-project | 2 +- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cohttp-eio/src/client.ml b/cohttp-eio/src/client.ml index 7525b074ff..fcb4e07934 100644 --- a/cohttp-eio/src/client.ml +++ b/cohttp-eio/src/client.ml @@ -6,7 +6,7 @@ type connection = Eio.Flow.two_way_ty r type t = sw:Switch.t -> Uri.t -> connection include - Cohttp.Client.Make + Cohttp.Generic.Client.Make (struct type 'a io = 'a type body = Body.t diff --git a/cohttp-eio/src/client.mli b/cohttp-eio/src/client.mli index e3276211fd..81e7dc5d8e 100644 --- a/cohttp-eio/src/client.mli +++ b/cohttp-eio/src/client.mli @@ -3,7 +3,7 @@ open Eio.Std type t include - Cohttp.Client.S + Cohttp.Generic.Client.S with type 'a with_context = t -> sw:Switch.t -> 'a and type 'a io = 'a and type body = Body.t diff --git a/cohttp-eio/src/server.mli b/cohttp-eio/src/server.mli index 079379c9e7..7a0bec7dce 100644 --- a/cohttp-eio/src/server.mli +++ b/cohttp-eio/src/server.mli @@ -1,4 +1,4 @@ -include Cohttp.Server.S with module IO = Io.IO and type body = Body.t +include Cohttp.Generic.Server.S with module IO = Io.IO and type body = Body.t val run : ?max_connections:int -> diff --git a/cohttp-lwt.opam b/cohttp-lwt.opam index 94c30b0f3c..46d388995d 100644 --- a/cohttp-lwt.opam +++ b/cohttp-lwt.opam @@ -29,7 +29,7 @@ depends: [ "ocaml" {>= "4.08"} "http" {= version} "cohttp" {= version} - "lwt" {>= "2.5.0"} + "lwt" {>= "5.4.0"} "sexplib0" "ppx_sexp_conv" {>= "v0.13.0"} "logs" diff --git a/cohttp-lwt/src/client.ml b/cohttp-lwt/src/client.ml index 8b8ba07087..f105d4fafb 100644 --- a/cohttp-lwt/src/client.ml +++ b/cohttp-lwt/src/client.ml @@ -17,7 +17,7 @@ module Make (Connection : S.Connection) = struct | Some ctx -> No_cache.(call (create ~ctx ())) include - Cohttp.Client.Make + Cohttp.Generic.Client.Make (struct type 'a io = 'a Lwt.t type body = Body.t diff --git a/cohttp-lwt/src/s.ml b/cohttp-lwt/src/s.ml index 395050ec74..a834e7965b 100644 --- a/cohttp-lwt/src/s.ml +++ b/cohttp-lwt/src/s.ml @@ -196,7 +196,7 @@ module type Client = sig interface rather than invoke this function directly. See {!head}, {!get} and {!post} for some examples. *) include - Cohttp.Client.S + Cohttp.Generic.Client.S with type 'a io = 'a Lwt.t and type body = Body.t and type 'a with_context = ?ctx:ctx -> 'a @@ -223,7 +223,7 @@ end (** The [Server] module implements a pipelined HTTP/1.1 server. *) module type Server = sig - include Cohttp.Server.S with type body = Body.t and type 'a IO.t = 'a Lwt.t + include Cohttp.Generic.Server.S with type body = Body.t and type 'a IO.t = 'a Lwt.t val resolve_local_file : docroot:string -> uri:Uri.t -> string [@@deprecated "Please use Cohttp.Path.resolve_local_file. "] diff --git a/cohttp/src/cohttp.ml b/cohttp/src/cohttp.ml index 95d9a7a751..a5aa7db985 100644 --- a/cohttp/src/cohttp.ml +++ b/cohttp/src/cohttp.ml @@ -1,7 +1,6 @@ module Accept = Accept module Auth = Auth module Body = Body -module Client = Client module Conf = Conf module Connection = Connection [@@deprecated "Connection.t values are useless."] module Code = Code @@ -11,10 +10,14 @@ module Link = Link module Request = Request module Response = Response module S = S -module Server = Server module Path = Path module Transfer = Transfer +module Generic = struct + module Client = Client + module Server = Server +end + module Private = struct module Transfer_io = Transfer_io module String_io = String_io diff --git a/dune-project b/dune-project index ba0d8ee983..5917eeb5ad 100644 --- a/dune-project +++ b/dune-project @@ -76,7 +76,7 @@ (cohttp (= :version)) (lwt - (>= 2.5.0)) + (>= 5.4.0)) sexplib0 (ppx_sexp_conv (>= v0.13.0)) From 59af795a877a0296d5283902299d785e5e1fa70d Mon Sep 17 00:00:00 2001 From: Marcello Seri Date: Tue, 31 Oct 2023 10:22:09 +0100 Subject: [PATCH 2/2] Update CHANGES Signed-off-by: Marcello Seri --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 30f300b0da..bed0d81e61 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ ## v6.0.0~beta1 (2023-10-27) +- cohttp-eio: move new Cohttp.{Client,Server} modules under Cohttp.Generic (mseri #1003) - cohttp-eio: Add Client.make_generic and HTTPS support. (talex5 #1002) - cohttp: move generic client and server signatures to cohttp and use them across all packges. (mefyl #984) - cohttp-eio: Complete rewrite to follow common interfaces and behaviors. (mefyl #984)