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

Copy Markdown View Source

What Macaw.Live.Proxy.Fetcher.Httpc performs its I/O through (spec/06 §1.6), a behavior over an argument: :httpc's asynchronous request and its cancel. The fetcher builds everything else (the peer verification its ssl options give, no redirect, the headers, the byte cap and the timeout), so a test hands it a transport of its own that records what it was given and answers as :httpc would, and no socket opens. Macaw.Live.Proxy.Fetcher.Httpc.Transport.Inets, OTP's :httpc, is the default.

request(arg, request, http_options, options) is one GET, request being :httpc's {url, headers} in charlists and the options :httpc.request/4's, stream: :self among them. It answers {:ok, ref} and the answer comes to the caller as :httpc's messages, {:http, {ref, ...}}, or {:error, reason}. cancel(arg, ref) stops a request; what it had sent already may still be in the caller's mailbox.

Summary

Callbacks

cancel(arg, ref)

@callback cancel(arg :: term(), ref :: reference()) :: :ok

request(arg, request, http_options, options)

@callback request(
  arg :: term(),
  request :: {charlist(), [{charlist(), charlist()}]},
  http_options :: keyword(),
  options :: keyword()
) :: {:ok, reference()} | {:error, term()}