Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

41 satır
1.0KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 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, %URI{scheme: "https"}) do
  22. Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
  23. end
  24. defp add_scheme_opts(opts, _), do: opts
  25. defp maybe_add_with_body(opts) do
  26. if opts[:max_body] do
  27. Keyword.put(opts, :with_body, true)
  28. else
  29. opts
  30. end
  31. end
  32. end