Eio_brr_io.FetchFetching resources.
See the Fetch API.
module Body : sig ... endBody specification and interface.
module Cache : sig ... endFetch caches.
module Ev : sig ... endFetch events.
val url :
?abort:Brr.Abort.t ->
?init:Brr_io.Fetch.Request.init ->
Jstr.t ->
Brr_io.Fetch.Response.turl ?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.
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)