Minimal, hardened HTTP client built on :httpc and :ssl.
https://requests always verify the peer certificate against the operating system trust store (:public_key.cacerts_get/0) and check the hostname.- Plain
http://is only allowed for loopback hosts (local test servers). - Successful responses are streamed with backpressure and aborted beyond
:max_body_bytes(default 50 MiB). For other responses,:httpcdelivers the buffered body before the client can check its size. - Partial responses are rejected because feed requests require a complete body.
- Transient failures (
502,503,504, timeouts, closed sockets) are retried up to two times with jitter. - Redirects are followed manually (at most 3) so every hop is validated.
The module implements the VulnCheck.HTTP behaviour itself; tests and
embedders can pass any other implementation through the :http_client
option accepted by the feed modules.
Summary
Functions
Performs a GET request.
TLS options used for https:// requests.
The User-Agent header value sent with every request.
Validates that a URL may be requested: https:// anywhere, http:// only
on loopback hosts.
Types
@type response() :: %{ status: non_neg_integer(), headers: %{required(String.t()) => String.t()}, body: binary() }
Callbacks
Functions
@spec get(String.t(), [{String.t(), String.t()}], keyword()) :: {:ok, response()} | {:error, term()}
Performs a GET request.
Options: :timeout, :connect_timeout, :max_body_bytes, :retries
(default 2), :retry_delay_ms (default 300) and :cacerts (trusted DER
certificates, defaults to the operating system trust store).
TLS options used for https:// requests.
@spec user_agent() :: String.t()
The User-Agent header value sent with every request.
Validates that a URL may be requested: https:// anywhere, http:// only
on loopback hosts.