logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

hackney.ex (928B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.HTTP.AdapterHelper.Hackney do
  5. @behaviour Pleroma.HTTP.AdapterHelper
  6. @defaults [
  7. follow_redirect: true,
  8. force_redirect: true
  9. ]
  10. @spec options(keyword(), URI.t()) :: keyword()
  11. def options(connection_opts \\ [], %URI{} = uri) do
  12. proxy = Pleroma.Config.get([:http, :proxy_url])
  13. config_opts = Pleroma.Config.get([:http, :adapter], [])
  14. @defaults
  15. |> Keyword.merge(config_opts)
  16. |> Keyword.merge(connection_opts)
  17. |> add_scheme_opts(uri)
  18. |> maybe_add_with_body()
  19. |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
  20. end
  21. defp add_scheme_opts(opts, _), do: opts
  22. defp maybe_add_with_body(opts) do
  23. if opts[:max_body] do
  24. Keyword.put(opts, :with_body, true)
  25. else
  26. opts
  27. end
  28. end
  29. end