1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.HTTP.AdapterHelper.Hackney do
6 @behaviour Pleroma.HTTP.AdapterHelper
13 @spec options(keyword(), URI.t()) :: keyword()
14 def options(connection_opts \\ [], %URI{} = uri) do
15 proxy = Pleroma.Config.get([:http, :proxy_url])
17 config_opts = Pleroma.Config.get([:http, :adapter], [])
20 |> Keyword.merge(config_opts)
21 |> Keyword.merge(connection_opts)
22 |> add_scheme_opts(uri)
23 |> maybe_add_with_body()
24 |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
27 defp add_scheme_opts(opts, %URI{scheme: "https"}) do
28 Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
31 defp add_scheme_opts(opts, _), do: opts
33 defp maybe_add_with_body(opts) do
35 Keyword.put(opts, :with_body, true)