Kantoor. Feeds. Http behaviour
(Kantoor v1.0.0)
One HTTPS request of a feed fetch, to an address that has already been checked
(Kantoor.Feeds.NetGuard). A behaviour so that tests use a stub and never reach
a network (config :kantoor, :feed_http).
The request carries the ip to connect to and the host to speak to it with
(TLS server name, certificate check, Host header), so the name is not resolved
a second time. The implementation does not follow redirects (that is
Kantoor.Feeds.Fetcher's job, which checks every hop) and enforces the limits
itself: the body may not exceed max_bytes, and the whole request must end
within timeout_ms.
Summary
Types
@type error() :: :timeout | :too_large | :tls | :connect | :bad_response
@type request() :: %{ optional(:port) => :inet.port_number(), optional(:cacerts) => [binary()], ip: :inet.ip_address(), host: String.t(), path: String.t(), headers: [{String.t(), String.t()}], max_bytes: pos_integer(), timeout_ms: pos_integer() }
@type response() :: %{ status: pos_integer(), headers: [{String.t(), String.t()}], body: binary() }
Callbacks
Functions
@spec impl() :: module()
The configured implementation.