1 defmodule Pleroma.HTTP.AdapterHelper.Hackney do
2 @behaviour Pleroma.HTTP.AdapterHelper
9 @spec options(keyword(), URI.t()) :: keyword()
10 def options(connection_opts \\ [], %URI{} = uri) do
11 proxy = Pleroma.Config.get([:http, :proxy_url])
13 config_opts = Pleroma.Config.get([:http, :adapter], [])
16 |> Keyword.merge(config_opts)
17 |> Keyword.merge(connection_opts)
18 |> add_scheme_opts(uri)
19 |> maybe_add_with_body()
20 |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
23 defp add_scheme_opts(opts, %URI{scheme: "https"}) do
24 Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
27 defp add_scheme_opts(opts, _), do: opts
29 defp maybe_add_with_body(opts) do
31 Keyword.put(opts, :with_body, true)