Outgoing requests, the stand-in for JavaScript's fetch(). Everything that calls another server (mail services, importers, connected installs, the assistant's providers, site icons) goes through the instance's fetcher, so tests can pass a fake.
A fetcher is a function of two arguments, the URL and options, that answers
{:ok, %Runlight.Http.Response{}} or {:error, reason} when no answer came
back (refused, timed out, bad TLS). The options:
:method- default "GET".:headers- a list of{name, value}pairs, names lowercase.:body- text.:redirect-:follow(default) or:manual, which hands back a 3xx.:timeout- the whole request's limit in milliseconds, default 30000.:max_bytes- stop reading past this and answer{:error, :too_long}, or withtruncate: truehand back the firstmax_bytes.:public- true to connect only to addresses on the public internet (Runlight.Safefetchsets it). A fetcher that cannot choose the address it connects to may ignore it, as Safefetch checks the name just before.
httpc/2 is the default, on Erlang's own :httpc with certificates
verified against the system's.
Summary
Functions
Fetches through :httpc.
Types
@type fetcher() :: (String.t(), keyword() -> {:ok, Runlight.Http.Response.t()} | {:error, term()})
Functions
@spec httpc(String.t(), keyword()) :: {:ok, Runlight.Http.Response.t()} | {:error, term()}
Fetches through :httpc.