Merge branch 'pool-usage' into 'develop'
[akkoma] / lib / pleroma / http / connection.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.HTTP.Connection do
6 @moduledoc """
7 Connection for http-requests.
8 """
9
10 @hackney_options [
11 timeout: 10000,
12 recv_timeout: 20000,
13 follow_redirect: true
14 ]
15 @adapter Application.get_env(:tesla, :adapter)
16
17 @doc """
18 Configure a client connection
19
20 # Returns
21
22 Tesla.Env.client
23 """
24 @spec new(Keyword.t()) :: Tesla.Env.client()
25 def new(opts \\ []) do
26 Tesla.client([], {@adapter, hackney_options(opts)})
27 end
28
29 # fetch Hackney options
30 #
31 defp hackney_options(opts) do
32 options = Keyword.get(opts, :adapter, [])
33 @hackney_options ++ options
34 end
35 end