summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex S <alex.strizhakov@gmail.com>2019-08-23 18:17:13 +0300
committerAlex S <alex.strizhakov@gmail.com>2019-08-23 18:17:13 +0300
commit431cf60510e05a8483847fe2c2025b79a3602a08 (patch)
treeabd017656f0bf63bb217d05dd6f8c1f0c3560770
parent65fd5bdf4cd1f70edd8669f0c90fcc6d9b4385ff (diff)
little refactoring
-rw-r--r--lib/pleroma/gun/connections.ex33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/pleroma/gun/connections.ex b/lib/pleroma/gun/connections.ex
index a0fa8e6eb..95398dd6c 100644
--- a/lib/pleroma/gun/connections.ex
+++ b/lib/pleroma/gun/connections.ex
@@ -160,26 +160,25 @@ defmodule Pleroma.Gun.Connections do
result =
if opts[:proxy] do
+ tls_opts = Map.get(opts, :tls_opts, [])
+ connect_opts = %{host: host, port: port}
+
+ connect_opts =
+ if uri.scheme == "https" do
+ Map.put(connect_opts, :protocols, [:http2])
+ |> Map.put(:transport, :tls)
+ |> Map.put(:tls_opts, tls_opts)
+ else
+ connect_opts
+ end
+
with {proxy_host, proxy_port} <- opts[:proxy],
- tls_opts <- Map.get(opts, :tls_opts, []),
open_opts <- Map.delete(opts, :tls_opts),
{:ok, conn} <- API.open(proxy_host, proxy_port, open_opts),
- {:ok, _} <- API.await_up(conn) do
- connect_opts = %{host: host, port: port}
-
- connect_opts =
- if uri.scheme == "https" do
- Map.put(connect_opts, :protocols, [:http2])
- |> Map.put(:transport, :tls)
- |> Map.put(:tls_opts, tls_opts)
- else
- connect_opts
- end
-
- with stream <- API.connect(conn, connect_opts),
- {:response, :fin, 200, _} <- API.await(conn, stream) do
- {:ok, conn, true}
- end
+ {:ok, _} <- API.await_up(conn),
+ stream <- API.connect(conn, connect_opts),
+ {:response, :fin, 200, _} <- API.await(conn, stream) do
+ {:ok, conn, true}
else
{:error, error} ->
{:error, error}