Dowser.Client.HTTP.Httpc (Dowser.Client v0.1.1)

View Source

HTTP adapter backed by OTP's built-in :httpc client.

Requires no extra dependency — :inets and :ssl ship with OTP and are started lazily on first use.

The HTTP version is pinned to HTTP/1.1. :httpc never speaks HTTP/2 and keeps connections alive by default (persistent sessions reused per host/port), so requests are HTTP/1.1 + keep-alive.

Options

  • :http_options — passed as :httpc's HTTPOptions (e.g. timeout, connect_timeout, ssl). version: ~c"HTTP/1.1" is always set. connect_timeout defaults to 2_000 and timeout to 30_000 (milliseconds); either can be overridden by the caller.
  • :options — passed as :httpc's Options. body_format: :binary is always set so the response body comes back as a binary.

Body support is method-dependent

:httpc only accepts a request body for :post, :put, :patch, :delete and :options — its request tuple for every other method (:get, :head, ...) has no slot for one. A body given for one of those methods returns {:error, {:unsupported_body, method}} rather than being silently dropped. This is a real backend-compatibility gap: search APIs that expect a body on GET (e.g. Elasticsearch's GET /_search) need Dowser.Client.HTTP.Req or Dowser.Client.HTTP.Hackney instead.