Module Eio_brr_io.Fetch

Fetching resources.

See the Fetch API.

module Body : sig ... end

Body specification and interface.

module Cache : sig ... end

Fetch caches.

module Ev : sig ... end

Fetch events.

val url : ?abort:Brr.Abort.t -> ?init:Brr_io.Fetch.Request.init -> Jstr.t -> Brr_io.Fetch.Response.t

url ?abort ~init u fetches URL u with the init request object. If the fiber is cancelled, the optional controller abort is aborted. This only cancels the fetch operation if the signal of abort is passed in init (Brr_io.Fetch.Request.init ~signal); url does not add it.

val request : ?abort:Brr.Abort.t -> Brr_io.Fetch.Request.t -> Brr_io.Fetch.Response.t

request ?abort r fetches request r. If the fiber is cancelled, the optional controller abort is aborted. This only cancels the fetch operation if r was created with the signal of abort.

Here is an example of how to use this API:

let fetch url =
  let abort = Brr.Abort.controller () in
  let init =
    Brr_io.Fetch.Request.init ~signal:(Brr.Abort.signal abort) ()
  in
  let response = Eio_brr_io.Fetch.url ~abort ~init url in
  Eio_brr_io.Fetch.Body.text ~abort
    (Brr_io.Fetch.Response.as_body response)