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

cohttp-mirage: support conduit 8.0.0 #1104

Merged
merged 3 commits into from
Mar 3, 2025
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: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
- cohttp: `Cohttp.Request.make_for_client` no longer allows setting both
`~chunked:true` and `~body_length`.
- cohttp-lwt-unix: Don't blow up when certificates are not available and no-network requests are made. (akuhlens #1027)
+ Makes `cohttp-lwt.S.default_ctx` lazy.
+ Makes `cohttp-lwt.S.default_ctx` lazy.
- cohttp-lwt-unix: Add http/https proxy support for client requests (MisterDA #1080)
- cohttp-mirage: Support conduit 8.0.0 (#@hannesm, #1104)

## v6.0.0~beta2 (2024-01-05)

Expand Down
3 changes: 1 addition & 2 deletions cohttp-eio.opam
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ depends: [
"logs"
"uri"
"tls-eio" {with-test & >= "1.0.0"}
"mirage-crypto-rng" {with-test & < "1.2.0"}
"mirage-crypto-rng-eio" {with-test & >= "0.11.2"}
"mirage-crypto-rng" {with-test & >= "1.2.0"}
"ca-certs" {with-test & >= "1.0.0"}
"fmt"
"ptime"
Expand Down
2 changes: 1 addition & 1 deletion cohttp-eio/examples/client_tls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let https ~authenticator =

let () =
Eio_main.run @@ fun env ->
Mirage_crypto_rng_eio.run (module Mirage_crypto_rng.Fortuna) env @@ fun () ->
Mirage_crypto_rng_unix.use_default ();
let client = Client.make ~https:(Some (https ~authenticator)) env#net in
Eio.Switch.run @@ fun sw ->
let resp, body =
Expand Down
2 changes: 1 addition & 1 deletion cohttp-eio/examples/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logs.threaded
tls-eio
ca-certs
mirage-crypto-rng-eio))
mirage-crypto-rng.unix))

(alias
(name runtest)
Expand Down
4 changes: 2 additions & 2 deletions cohttp-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ depends: [
"ocaml" {>= "4.08"}
"mirage-flow" {>= "2.0.0"}
"mirage-channel" {>= "4.0.0"}
"conduit" {>= "2.0.2"}
"conduit-mirage" {>= "2.3.0"}
"conduit" {>= "8.0.0"}
"conduit-mirage" {>= "8.0.0"}
"mirage-kv" {>= "3.0.0"}
"lwt" {>= "2.4.3"}
"cohttp-lwt" {= version}
Expand Down
8 changes: 2 additions & 6 deletions cohttp-mirage/src/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
* %%NAME%% %%VERSION%%
*)

module Make
(P : Mirage_clock.PCLOCK)
(R : Resolver_mirage.S)
(S : Conduit_mirage.S) =
struct
module Net = Net.Make (P) (R) (S)
module Make (R : Resolver_mirage.S) (S : Conduit_mirage.S) = struct
module Net = Net.Make (R) (S)
module Connection = Cohttp_lwt.Connection.Make (Net)
include Cohttp_lwt.Client.Make (Connection)

Expand Down
5 changes: 1 addition & 4 deletions cohttp-mirage/src/client.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module Make
(_ : Mirage_clock.PCLOCK)
(R : Resolver_mirage.S)
(S : Conduit_mirage.S) : sig
module Make (R : Resolver_mirage.S) (S : Conduit_mirage.S) : sig
module Connection : Cohttp_lwt.S.Connection
include Cohttp_lwt.S.Client with type ctx = Connection.Net.ctx

Expand Down
10 changes: 3 additions & 7 deletions cohttp-mirage/src/net.ml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
module Make
(P : Mirage_clock.PCLOCK)
(R : Resolver_mirage.S)
(S : Conduit_mirage.S) =
struct
module Make (R : Resolver_mirage.S) (S : Conduit_mirage.S) = struct
module Channel = Mirage_channel.Make (S.Flow)
module Input_channel = Input_channel.Make (Channel)
module Endpoint = Conduit_mirage.Endpoint (P)
module IO = Io.Make (Channel)
open IO

Expand All @@ -28,7 +23,8 @@ struct
let resolve ~ctx uri = R.resolve_uri ~uri ctx.resolver

let connect_endp ~ctx endp =
Endpoint.client ?tls_authenticator:ctx.authenticator endp >>= fun client ->
Conduit_mirage.Endpoint.client ?tls_authenticator:ctx.authenticator endp
>>= fun client ->
match ctx.conduit with
| None -> failwith "conduit not initialised"
| Some c ->
Expand Down
5 changes: 1 addition & 4 deletions cohttp-mirage/src/net.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module Make
(_ : Mirage_clock.PCLOCK)
(R : Resolver_mirage.S)
(S : Conduit_mirage.S) : sig
module Make (R : Resolver_mirage.S) (S : Conduit_mirage.S) : sig
type ctx = {
resolver : R.t;
conduit : S.t option;
Expand Down
7 changes: 3 additions & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@
(mirage-channel
(>= 4.0.0))
(conduit
(>= 2.0.2))
(>= 8.0.0))
(conduit-mirage
(>= 2.3.0))
(>= 8.0.0))
(mirage-kv
(>= 3.0.0))
(lwt
Expand Down Expand Up @@ -382,8 +382,7 @@
logs
uri
(tls-eio (and :with-test (>= 1.0.0)))
(mirage-crypto-rng (and :with-test (< 1.2.0)))
(mirage-crypto-rng-eio (and :with-test (>= 0.11.2)))
(mirage-crypto-rng (and :with-test (>= 1.2.0)))
(ca-certs (and :with-test (>= "1.0.0")))
fmt
ptime
Expand Down
Loading