1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.HTTP.Connection do
7 Connection for http-requests.
11 connect_timeout: 2_000,
13 follow_redirect: true,
16 @adapter Application.get_env(:tesla, :adapter)
19 Configure a client connection
25 @spec new(Keyword.t()) :: Tesla.Env.client()
26 def new(opts \\ []) do
27 Tesla.client([], {@adapter, hackney_options(opts)})
30 # fetch Hackney options
32 defp hackney_options(opts) do
33 options = Keyword.get(opts, :adapter, [])
34 adapter_options = Pleroma.Config.get([:http, :adapter], [])
37 |> Keyword.merge(adapter_options)
38 |> Keyword.merge(options)