http timeout config (#307)
[akkoma] / lib / pleroma / http / adapter_helper / default.ex
index 8567a616b6e8f7852925bf39c39c3c1722f06514..fc377b3762c36918a2a5c445a250ba69acc06511 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.HTTP.AdapterHelper.Default do
@@ -9,8 +9,14 @@ defmodule Pleroma.HTTP.AdapterHelper.Default do
 
   @spec options(keyword(), URI.t()) :: keyword()
   def options(opts, _uri) do
-    proxy = Pleroma.Config.get([:http, :proxy_url], nil)
-    AdapterHelper.maybe_add_proxy(opts, AdapterHelper.format_proxy(proxy))
+    proxy = Pleroma.Config.get([:http, :proxy_url])
+    pool_timeout = Pleroma.Config.get([:http, :pool_timeout], 5000)
+    receive_timeout = Pleroma.Config.get([:http, :receive_timeout], 15_000)
+
+    opts
+    |> AdapterHelper.maybe_add_proxy(AdapterHelper.format_proxy(proxy))
+    |> Keyword.put(:pool_timeout, pool_timeout)
+    |> Keyword.put(:receive_timeout, receive_timeout)
   end
 
   @spec get_conn(URI.t(), keyword()) :: {:ok, keyword()}