aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/gun/connections.ex2
-rw-r--r--lib/pleroma/http/http.ex4
-rw-r--r--test/reverse_proxy/reverse_proxy_test.exs12
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/pleroma/gun/connections.ex b/lib/pleroma/gun/connections.ex
index cec3de2ca..b6845e52d 100644
--- a/lib/pleroma/gun/connections.ex
+++ b/lib/pleroma/gun/connections.ex
@@ -46,7 +46,7 @@ defmodule Pleroma.Gun.Connections do
# TODO: only for testing, add this parameter to the config
@spec try_to_get_gun_conn(String.t(), keyword(), atom()) :: nil | pid()
- def try_to_get_gun_conn(url, opts \\ [], name \\ __MODULE__),
+ def try_to_get_gun_conn(url, opts \\ [], name \\ :default),
do: try_to_get_gun_conn(url, opts, name, 0)
@spec try_to_get_gun_conn(String.t(), keyword(), atom(), pos_integer()) :: nil | pid()
diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex
index a7f42d0c0..26ab0bb03 100644
--- a/lib/pleroma/http/http.ex
+++ b/lib/pleroma/http/http.ex
@@ -62,7 +62,9 @@ defmodule Pleroma.HTTP do
end
defp get_conn_for_gun(url, options) do
- case Pleroma.Gun.Connections.get_conn(url, options) do
+ pool = if options[:adapter][:pool], do: options[:adapter][:pool], else: :default
+
+ case Pleroma.Gun.Connections.try_to_get_gun_conn(url, options, pool) do
nil ->
options
diff --git a/test/reverse_proxy/reverse_proxy_test.exs b/test/reverse_proxy/reverse_proxy_test.exs
index 476cff643..8235fcc86 100644
--- a/test/reverse_proxy/reverse_proxy_test.exs
+++ b/test/reverse_proxy/reverse_proxy_test.exs
@@ -356,7 +356,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
- {:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
+
+ {:ok, _} =
+ Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "http://httpbin.org/stream-bytes/10")
@@ -379,7 +381,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
- {:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
+
+ {:ok, _} =
+ Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "https://httpbin.org/stream-bytes/10")
@@ -402,7 +406,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
- {:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
+
+ {:ok, _} =
+ Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "https://httpbin.org/redirect/5")