diff --git a/git-cohttp-mirage.opam b/git-cohttp-mirage.opam new file mode 100644 index 000000000..c07fa704d --- /dev/null +++ b/git-cohttp-mirage.opam @@ -0,0 +1,30 @@ +opam-version: "2.0" +maintainer: [ "thomas@gazagnaire.org" + "romain.calascibetta@gmail.com" ] +authors: "Thomas Gazagnaire" +license: "ISC" +homepage: "https://github.com/mirage/ocaml-git" +bug-reports: "https://github.com/mirage/ocaml-git/issues" +dev-repo: "git+https://github.com/mirage/ocaml-git.git" +doc: "https://mirage.github.io/ocaml-git/" +synopsis: "A package to use HTTP-based ocaml-git with MirageOS backend" + +build: [ + ["dune" "subst"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j1" "--no-buffer"] {with-test} +] + +depends: [ + "ocaml" {>= "4.07.0"} + "dune" {>= "2.6.0"} + "git" + "cohttp-mirage" +] + +pin-depends: [ + [ "conduit-mirage.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "cohttp.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-lwt.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-mirage.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] +] diff --git a/git-cohttp-unix.opam b/git-cohttp-unix.opam new file mode 100644 index 000000000..5de192d0f --- /dev/null +++ b/git-cohttp-unix.opam @@ -0,0 +1,32 @@ +opam-version: "2.0" +maintainer: [ "thomas@gazagnaire.org" + "romain.calascibetta@gmail.com" ] +authors: "Thomas Gazagnaire" +license: "ISC" +homepage: "https://github.com/mirage/ocaml-git" +bug-reports: "https://github.com/mirage/ocaml-git/issues" +dev-repo: "git+https://github.com/mirage/ocaml-git.git" +doc: "https://mirage.github.io/ocaml-git/" +synopsis: "A package to use HTTP-based ocaml-git with Unix backend" + +build: [ + ["dune" "subst"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j1" "--no-buffer"] {with-test} +] + +depends: [ + "ocaml" {>= "4.07.0"} + "dune" {>= "2.6.0"} + "git" + "cohttp-lwt-unix" +] + +pin-depends: [ + [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "conduit-lwt.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "conduit-lwt-ssl.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "cohttp.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-lwt.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-lwt-unix.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] +] diff --git a/git-cohttp.opam b/git-cohttp.opam new file mode 100644 index 000000000..0ff0f7ef9 --- /dev/null +++ b/git-cohttp.opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +maintainer: [ "thomas@gazagnaire.org" + "romain.calascibetta@gmail.com" ] +authors: "Thomas Gazagnaire" +license: "ISC" +homepage: "https://github.com/mirage/ocaml-git" +bug-reports: "https://github.com/mirage/ocaml-git/issues" +dev-repo: "git+https://github.com/mirage/ocaml-git.git" +doc: "https://mirage.github.io/ocaml-git/" +synopsis: "A package to use HTTP-based ocaml-git with Unix backend" + +build: [ + ["dune" "subst"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j1" "--no-buffer"] {with-test} +] + +depends: [ + "ocaml" {>= "4.07.0"} + "dune" {>= "2.6.0"} + "git" +] + +pin-depends: [ + [ "cohttp.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#9f19f9b8216f2546f2917b08ff227be5630858bf" ] + [ "cohttp-lwt.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#9f19f9b8216f2546f2917b08ff227be5630858bf" ] +] diff --git a/git-mirage.opam b/git-mirage.opam index ca849e9d6..5f052ce87 100644 --- a/git-mirage.opam +++ b/git-mirage.opam @@ -23,8 +23,8 @@ depends: [ ] pin-depends: [ - [ "conduit-mirage.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9815aa091e9c285e236e1deffb0dc48723ac72a0" ] - [ "cohttp.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#9f19f9b8216f2546f2917b08ff227be5630858bf" ] - [ "cohttp-lwt.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#9f19f9b8216f2546f2917b08ff227be5630858bf" ] - [ "cohttp-mirage.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#9f19f9b8216f2546f2917b08ff227be5630858bf" ] + [ "conduit-mirage.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "cohttp.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-lwt.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] + [ "cohttp-mirage.dev" "git+https://github.com/dinosaure/ocaml-cohttp.git#11dc50bf1ee6e3df831e76ebcc25a5c9f3abc280" ] ] diff --git a/git-unix.opam b/git-unix.opam index 5f982bfba..651a89cd2 100644 --- a/git-unix.opam +++ b/git-unix.opam @@ -43,6 +43,6 @@ depends: [ ] pin-depends: [ - [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9815aa091e9c285e236e1deffb0dc48723ac72a0" ] - [ "conduit-lwt.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9815aa091e9c285e236e1deffb0dc48723ac72a0" ] + [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "conduit-lwt.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] ] diff --git a/git.opam b/git.opam index 9efe8643d..7d4dde0de 100644 --- a/git.opam +++ b/git.opam @@ -59,6 +59,6 @@ depends: [ ] pin-depends: [ - [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9779d777cd03f85e770ecc1c1174dd382979bc58" ] + [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] [ "encore.dev" "git+https://github.com/mirage/encore.git#d376be363e0fb26c0c04d334931a4519a0c30878" ] ] diff --git a/nss.opam b/nss.opam index 9cb6f24be..775b9cf49 100644 --- a/nss.opam +++ b/nss.opam @@ -47,6 +47,6 @@ depends: [ ] pin-depends: [ - [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9815aa091e9c285e236e1deffb0dc48723ac72a0" ] - [ "conduit-lwt.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#9815aa091e9c285e236e1deffb0dc48723ac72a0" ] + [ "conduit.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] + [ "conduit-lwt.dev" "git+https://github.com/dinosaure/ocaml-conduit.git#056e94b57e6fc2a08b587e949a7c38d2f1b79e6a" ] ] diff --git a/src/git-cohttp-mirage/dune b/src/git-cohttp-mirage/dune new file mode 100644 index 000000000..77295aed6 --- /dev/null +++ b/src/git-cohttp-mirage/dune @@ -0,0 +1,5 @@ +(library + (name git_cohttp_mirage) + (public_name git-cohttp-mirage) + (libraries git-cohttp lwt rresult result nss.git uri fmt cohttp cohttp-lwt + cohttp-mirage)) diff --git a/src/git-cohttp-mirage/git_cohttp_mirage.ml b/src/git-cohttp-mirage/git_cohttp_mirage.ml new file mode 100644 index 000000000..3556b2339 --- /dev/null +++ b/src/git-cohttp-mirage/git_cohttp_mirage.ml @@ -0,0 +1 @@ +include Git_cohttp.Make (Cohttp_mirage.Client) diff --git a/src/git-cohttp-mirage/git_cohttp_mirage.mli b/src/git-cohttp-mirage/git_cohttp_mirage.mli new file mode 100644 index 000000000..7a50c8448 --- /dev/null +++ b/src/git-cohttp-mirage/git_cohttp_mirage.mli @@ -0,0 +1 @@ +include Smart_git.HTTP diff --git a/src/git-cohttp-unix/dune b/src/git-cohttp-unix/dune new file mode 100644 index 000000000..e429dd9d6 --- /dev/null +++ b/src/git-cohttp-unix/dune @@ -0,0 +1,5 @@ +(library + (name git_cohttp_unix) + (public_name git-cohttp-unix) + (libraries git-cohttp lwt rresult result nss.git uri fmt cohttp cohttp-lwt + cohttp-lwt-unix)) diff --git a/src/git-cohttp-unix/git_cohttp_unix.ml b/src/git-cohttp-unix/git_cohttp_unix.ml new file mode 100644 index 000000000..4c4db0ca6 --- /dev/null +++ b/src/git-cohttp-unix/git_cohttp_unix.ml @@ -0,0 +1 @@ +include Git_cohttp.Make (Cohttp_lwt_unix.Client) diff --git a/src/git-cohttp-unix/git_cohttp_unix.mli b/src/git-cohttp-unix/git_cohttp_unix.mli new file mode 100644 index 000000000..7a50c8448 --- /dev/null +++ b/src/git-cohttp-unix/git_cohttp_unix.mli @@ -0,0 +1 @@ +include Smart_git.HTTP diff --git a/src/git-cohttp/dune b/src/git-cohttp/dune index c0ed58d8f..38dbf93f2 100644 --- a/src/git-cohttp/dune +++ b/src/git-cohttp/dune @@ -1,5 +1,4 @@ (library (name git_cohttp) - (public_name git-mirage.cohttp) - (libraries lwt rresult result nss.git uri fmt cohttp cohttp-lwt - cohttp-mirage)) + (public_name git-cohttp) + (libraries conduit lwt rresult result nss.git uri fmt cohttp cohttp-lwt)) diff --git a/src/git-cohttp/git_cohttp.ml b/src/git-cohttp/git_cohttp.ml index b96e43978..587782e2b 100644 --- a/src/git-cohttp/git_cohttp.ml +++ b/src/git-cohttp/git_cohttp.ml @@ -1,17 +1,21 @@ open Lwt.Infix -type error = | +module Make + (Cohttp_client : Cohttp_lwt.S.Client with type resolvers = Conduit.resolvers) = +struct + type error = | -let pp_error : error Fmt.t = fun _ppf -> function _ -> . + let pp_error : error Fmt.t = fun _ppf -> function _ -> . -let get ~resolvers ?(headers = []) uri = - let headers = Cohttp.Header.of_list headers in - Cohttp_mirage.Client.get ~resolvers ~headers uri >>= fun (_response, body) -> - Cohttp_lwt.Body.to_string body >>= fun body -> Lwt.return_ok ((), body) + let get ~resolvers ?(headers = []) uri = + let headers = Cohttp.Header.of_list headers in + Cohttp_client.get ~resolvers ~headers uri >>= fun (_response, body) -> + Cohttp_lwt.Body.to_string body >>= fun body -> Lwt.return_ok ((), body) -let post ~resolvers ?(headers = []) uri body = - let headers = Cohttp.Header.of_list headers in - let body = Cohttp_lwt.Body.of_string body in - Cohttp_mirage.Client.post ~resolvers ~headers ~chunked:false ~body uri - >>= fun (_response, body) -> - Cohttp_lwt.Body.to_string body >>= fun body -> Lwt.return_ok ((), body) + let post ~resolvers ?(headers = []) uri body = + let headers = Cohttp.Header.of_list headers in + let body = Cohttp_lwt.Body.of_string body in + Cohttp_client.post ~resolvers ~headers ~chunked:false ~body uri + >>= fun (_response, body) -> + Cohttp_lwt.Body.to_string body >>= fun body -> Lwt.return_ok ((), body) +end diff --git a/src/git-cohttp/git_cohttp.mli b/src/git-cohttp/git_cohttp.mli index 7a50c8448..d23fac0a5 100644 --- a/src/git-cohttp/git_cohttp.mli +++ b/src/git-cohttp/git_cohttp.mli @@ -1 +1,3 @@ -include Smart_git.HTTP +module Make + (Cohttp_client : Cohttp_lwt.S.Client with type resolvers = Conduit.resolvers) : + Smart_git.HTTP