1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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
11 @spec options(keyword(), URI.t()) :: keyword()
12 def options(connection_opts \\ [], %URI{} = uri) do
13 proxy = Pleroma.Config.get([:http, :proxy_url])
15 config_opts = Pleroma.Config.get([:http, :adapter], [])
18 |> Keyword.merge(config_opts)
19 |> Keyword.merge(connection_opts)
20 |> add_scheme_opts(uri)
21 |> maybe_add_with_body()
22 |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
25 defp add_scheme_opts(opts, _), do: opts
27 defp maybe_add_with_body(opts) do
29 Keyword.put(opts, :with_body, true)