FindSiteIcon.Util.HTTPUtils (FindSiteIcon v1.0.2)

Copy Markdown View Source

Small wrapper around Req with project defaults.

Accepts the same options as Req.new/1, plus the following defaults that callers may override by passing the key explicitly:

  • :timeout -> applied to both connect and receive timeouts. Defaults to 30s.
  • :pool_max_idle_time -> milliseconds before idle Finch socket pools are terminated. Defaults to 30s so file descriptors are reclaimed when probing many distinct hosts. Pass :infinity to keep pools alive forever, which was Req's behaviour prior to find_site_icon 1.0.2. See issue #15.

Summary

Functions

do_get(url, headers \\ [], opts \\ [])

@spec do_get(binary() | Req.Request.t(), keyword(), keyword()) ::
  {:error, Exception.t()} | {:ok, Req.Response.t()}

do_head(url, headers \\ [], opts \\ [])

@spec do_head(binary() | Req.Request.t(), keyword(), keyword()) ::
  {:error, Exception.t()} | {:ok, Req.Response.t()}

new(opts \\ [])

@spec new(keyword()) :: Req.Request.t()