Macaw.Live.Proxy.Fetcher behaviour (macaw_live v0.1.0)

Copy Markdown View Source

How the proxy fetches upstream (spec/06 §1.6), a behavior over an argument, so a test passes a fetcher of its own and the proxy's suite reaches no network. Copied from visualize's Visualize.TileProxy.Fetcher, now given the request's headers and bounds.

fetch(arg, url, headers, opts) is one GET of url with exactly headers, opts carrying max_bytes: and timeout:. It follows no redirect: an upstream 3xx is answered as it came. It stops reading at max_bytes:, so an oversized body is never held whole: {:error, :too_large}. Macaw.Live.Proxy.Fetcher.Httpc is the default.

Summary

Callbacks

fetch(arg, url, headers, opts)

@callback fetch(
  arg :: term(),
  url :: String.t(),
  headers :: [{String.t(), String.t()}],
  opts :: keyword()
) ::
  {:ok,
   %{status: pos_integer(), headers: [{String.t(), String.t()}], body: binary()}}
  | {:error, :too_large | :timeout | term()}