Assent.HTTPAdapter.Httpc (Assent v0.4.0)

Copy Markdown View Source

HTTP adapter module for making http requests with :httpc.

You can override the :httpc options by updating the configuration:

http_adapter: {Assent.HTTPAdapter.Httpc, [...]}

Redirects are not followed by default, so credentials in headers and the request body are never sent to another URL. You can enable them with :autoredirect:

http_adapter: {Assent.HTTPAdapter.Httpc, autoredirect: true}

See Assent.HTTPAdapter for more.

TLS

By default, the :ssl options are:

[
  cacerts: :public_key.cacerts_get(),
  customize_hostname_check: [
    match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
  ],
  verify: :verify_peer
]

You can configure the :ssl options, which are merged on top of the defaults:

http_adapter: {Assent.HTTPAdapter.Httpc, ssl: [cacertfile: ~c"/path/to/ca.pem"]}

HTTPS requests configured with verify: :verify_none are rejected. You can pass in a custom :verify_fun to handle certificate verification manually:

http_adapter: {Assent.HTTPAdapter.Httpc, ssl: [verify_fun: {&MyModule.verify_fun/3, nil}]}