diff --git a/lib/pleroma/http/adapter.ex b/lib/pleroma/http/adapter_helper.ex
similarity index 96%
rename from lib/pleroma/http/adapter.ex
rename to lib/pleroma/http/adapter_helper.ex
index a3b84d8f3..2c13666ec 100644
--- a/lib/pleroma/http/adapter.ex
+++ b/lib/pleroma/http/adapter_helper.ex
@@ -2,7 +2,7 @@
# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.HTTP.Adapter do
+defmodule Pleroma.HTTP.AdapterHelper do
alias Pleroma.HTTP.Connection
@type proxy ::
diff --git a/lib/pleroma/http/adapter/gun.ex b/lib/pleroma/http/adapter_helper/gun.ex
similarity index 94%
rename from lib/pleroma/http/adapter/gun.ex
rename to lib/pleroma/http/adapter_helper/gun.ex
index ecf9c5b62..b3298ec7f 100644
--- a/lib/pleroma/http/adapter/gun.ex
+++ b/lib/pleroma/http/adapter_helper/gun.ex
@@ -2,10 +2,10 @@
# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.HTTP.Adapter.Gun do
- @behaviour Pleroma.HTTP.Adapter
+defmodule Pleroma.HTTP.AdapterHelper.Gun do
+ @behaviour Pleroma.HTTP.AdapterHelper
- alias Pleroma.HTTP.Adapter
+ alias Pleroma.HTTP.AdapterHelper
require Logger
@@ -28,7 +28,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
|> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
|> add_original(uri)
|> add_scheme_opts(uri)
- |> Adapter.maybe_add_proxy(Adapter.format_proxy(proxy))
+ |> AdapterHelper.maybe_add_proxy(AdapterHelper.format_proxy(proxy))
|> maybe_get_conn(uri, connection_opts)
end
diff --git a/lib/pleroma/http/adapter/hackney.ex b/lib/pleroma/http/adapter_helper/hackney.ex
similarity index 87%
rename from lib/pleroma/http/adapter/hackney.ex
rename to lib/pleroma/http/adapter_helper/hackney.ex
index 00db30083..a0e161eaa 100644
--- a/lib/pleroma/http/adapter/hackney.ex
+++ b/lib/pleroma/http/adapter_helper/hackney.ex
@@ -1,5 +1,5 @@
-defmodule Pleroma.HTTP.Adapter.Hackney do
- @behaviour Pleroma.HTTP.Adapter
+defmodule Pleroma.HTTP.AdapterHelper.Hackney do
+ @behaviour Pleroma.HTTP.AdapterHelper
@defaults [
connect_timeout: 10_000,
@@ -17,7 +17,7 @@ defmodule Pleroma.HTTP.Adapter.Hackney do
|> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
|> Keyword.merge(connection_opts)
|> add_scheme_opts(uri)
- |> Pleroma.HTTP.Adapter.maybe_add_proxy(proxy)
+ |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
end
defp add_scheme_opts(opts, %URI{scheme: "http"}), do: opts
diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex
index bdd062929..dc2761182 100644
--- a/lib/pleroma/http/connection.ex
+++ b/lib/pleroma/http/connection.ex
@@ -18,7 +18,7 @@ defmodule Pleroma.HTTP.Connection do
require Logger
alias Pleroma.Config
- alias Pleroma.HTTP.Adapter
+ alias Pleroma.HTTP.AdapterHelper
@doc """
Merge default connection & adapter options with received ones.
@@ -50,9 +50,9 @@ defmodule Pleroma.HTTP.Connection do
defp adapter do
case Application.get_env(:tesla, :adapter) do
- Tesla.Adapter.Gun -> Adapter.Gun
- Tesla.Adapter.Hackney -> Adapter.Hackney
- _ -> Adapter
+ Tesla.Adapter.Gun -> AdapterHelper.Gun
+ Tesla.Adapter.Hackney -> AdapterHelper.Hackney
+ _ -> AdapterHelper
end
end
diff --git a/test/http/adapter/gun_test.exs b/test/http/adapter_helper/gun_test.exs
similarity index 99%
rename from test/http/adapter/gun_test.exs
rename to test/http/adapter_helper/gun_test.exs
index a05471ac6..bc7e3f0e0 100644
--- a/test/http/adapter/gun_test.exs
+++ b/test/http/adapter_helper/gun_test.exs
@@ -2,13 +2,13 @@
# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.HTTP.Adapter.GunTest do
+defmodule Pleroma.HTTP.AdapterHelper.GunTest do
use ExUnit.Case, async: true
use Pleroma.Tests.Helpers
import ExUnit.CaptureLog
alias Pleroma.Config
alias Pleroma.Gun.Conn
- alias Pleroma.HTTP.Adapter.Gun
+ alias Pleroma.HTTP.AdapterHelper.Gun
alias Pleroma.Pool.Connections
setup_all do
diff --git a/test/http/adapter/hackney_test.exs b/test/http/adapter_helper/hackney_test.exs
similarity index 93%
rename from test/http/adapter/hackney_test.exs
rename to test/http/adapter_helper/hackney_test.exs
index 35cb58125..82f5a7883 100644
--- a/test/http/adapter/hackney_test.exs
+++ b/test/http/adapter_helper/hackney_test.exs
@@ -2,12 +2,12 @@
# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.HTTP.Adapter.HackneyTest do
+defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
use ExUnit.Case
use Pleroma.Tests.Helpers
alias Pleroma.Config
- alias Pleroma.HTTP.Adapter.Hackney
+ alias Pleroma.HTTP.AdapterHelper.Hackney
setup_all do
uri = URI.parse("http://domain.com")
diff --git a/test/http/adapter_helper_test.exs b/test/http/adapter_helper_test.exs
new file mode 100644
index 000000000..24d501ad5
--- /dev/null
+++ b/test/http/adapter_helper_test.exs
@@ -0,0 +1,28 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HTTP.AdapterHelperTest do
+ use ExUnit.Case, async: true
+
+ alias Pleroma.HTTP.AdapterHelper
+
+ describe "format_proxy/1" do
+ test "with nil" do
+ assert AdapterHelper.format_proxy(nil) == nil
+ end
+
+ test "with string" do
+ assert AdapterHelper.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
+ end
+
+ test "localhost with port" do
+ assert AdapterHelper.format_proxy("localhost:8123") == {'localhost', 8123}
+ end
+
+ test "tuple" do
+ assert AdapterHelper.format_proxy({:socks4, :localhost, 9050}) ==
+ {:socks4, 'localhost', 9050}
+ end
+ end
+end
diff --git a/test/http/adapter_test.exs b/test/http/adapter_test.exs
deleted file mode 100644
index 4c805837c..000000000
--- a/test/http/adapter_test.exs
+++ /dev/null
@@ -1,27 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.HTTP.AdapterTest do
- use ExUnit.Case, async: true
-
- alias Pleroma.HTTP.Adapter
-
- describe "format_proxy/1" do
- test "with nil" do
- assert Adapter.format_proxy(nil) == nil
- end
-
- test "with string" do
- assert Adapter.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
- end
-
- test "localhost with port" do
- assert Adapter.format_proxy("localhost:8123") == {'localhost', 8123}
- end
-
- test "tuple" do
- assert Adapter.format_proxy({:socks4, :localhost, 9050}) == {:socks4, 'localhost', 9050}
- end
- end
-end