1 defmodule Pleroma.HTTP.AdapterHelper.Hackney do
2 @behaviour Pleroma.HTTP.AdapterHelper
5 connect_timeout: 10_000,
12 @spec options(keyword(), URI.t()) :: keyword()
13 def options(connection_opts \\ [], %URI{} = uri) do
14 proxy = Pleroma.Config.get([:http, :proxy_url], nil)
16 config_opts = Pleroma.Config.get([:http, :adapter], [])
19 |> Keyword.merge(config_opts)
20 |> Keyword.merge(connection_opts)
21 |> add_scheme_opts(uri)
22 |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
25 defp add_scheme_opts(opts, %URI{scheme: "http"}), do: opts
27 defp add_scheme_opts(opts, %URI{scheme: "https", host: host}) do
30 # Workaround for remote server certificate chain issues
31 partial_chain: &:hackney_connect.partial_chain/1,
33 # We don't support TLS v1.3 yet
34 versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
35 server_name_indication: to_charlist(host)
39 Keyword.merge(opts, ssl_opts)
42 def after_request(_), do: :ok