package http-mirage-client

All checked builds pass
  1. Overview
  2. Docs
HTTP client for MirageOS

Install

dune-project
 Dependency

Authors

Maintainers

Sources

http-mirage-client-0.0.11.tbz
sha256=b0d97f1af1c04df2caca6cb97fdd465099328ce823a58228bae167b48cc4f823
sha512=c09457c364076afc0e3396286c4d6def5d6234fa6caea4e565b3b01b78969916e3c52b353193522884c34b8d9433873f20308f731ddd0cc6a830abdbf5cc0105

Description

Added to opam-repository:

README

An HTTP (http/1.1 or h2) client for MirageOS

This little library provides an HTTP client which can be usable inside a unikernel/MirageOS. It follows the same API as http-lwt-client which is pretty simple and uses:

This library wants to be easy to use and it is associated to a MirageOS device in order to facilite functoria to compose everything (mainly the TCP/IP stack) according to the user's target and give a witness so as to be able to allocate a new connection to a peer and process the HTTP flow.

How to use it?

First, you need to describe a new http_client device:

open Mirage

type http_client = HTTP_client
let http_client = typ HTTP_client

let http_client =
  let connect _ modname = function
    | [ _tcpv4v6; ctx ] ->
      Fmt.str {ocaml|%s.connect %s|ocaml} modname ctx
    | _ -> assert false in
  impl ~connect "Http_mirage_client.Make"
    (tcpv4v6 @-> git_client @-> http_client)

Then, you can decide how to construct such device:

let stack = generic_stackv4v6 default_network
let dns   = generic_dns_client stack
let tcp   = tcpv4v6_of_stackv4v6 stack

let http_client =
  (* XXX(dinosaure): it seems unconventional to use [git_happy_eyeballs] here
     when we want to do HTTP requests only. The name was not so good and we
     will fix that into the next release of the mirage tool. But structurally,
     you don't bring anything related to Git. It's just a bad choice of name. *)
  let happy_eyeballs = git_happy_eyeballs stack dns
    (generic_happy_eyeballs stack dns) in
  http_client $ default_posix_clock $ tcp $ happy_eyeballs

Finally, you can use the witness into your unikernel.ml:

open Lwt.Infix

module Make (HTTP_client : Http_mirage_client.S) = struct
  let start http_client =
    let body_f _response acc data = Lwt.return (acc ^ data) in
    Http_mirage_client.one_request http_client "https://mirage.io/" body_f ""
    >>= function
    | Ok (resp, body) -> ...
    | Error _ -> ...
end

Dependencies (12)

  1. ca-certs-nss >= "3.108-1"
  2. x509 >= "1.0.0"
  3. tls-mirage
  4. tls >= "1.0.0"
  5. h1
  6. h2 >= "0.12.0"
  7. mimic-happy-eyeballs >= "0.0.9"
  8. lwt >= "5.5.0"
  9. tcpip >= "7.0.0"
  10. paf >= "0.8.0"
  11. ocaml >= "4.11.0"
  12. dune >= "2.3"

Dev Dependencies (4)

  1. happy-eyeballs-mirage with-test & >= "2.0.0"
  2. dns-client-mirage with-test & >= "10.0.0"
  3. mirage-crypto-rng with-test
  4. alcotest-lwt with-test & >= "1.0.0"

Optional Dependencies

None

Used by (1)

  1. letsencrypt-mirage != "1.0.0"

Conflicts

None

Build status

Results of building http-mirage-client with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.0.11 (this version) n/a good good good good
0.0.6 good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure