little refactoring

This commit is contained in:
Alex S 2019-08-23 18:17:13 +03:00
parent 65fd5bdf4c
commit 431cf60510

View File

@ -160,11 +160,7 @@ defmodule Pleroma.Gun.Connections do
result =
if opts[:proxy] do
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
tls_opts = Map.get(opts, :tls_opts, [])
connect_opts = %{host: host, port: port}
connect_opts =
@ -176,10 +172,13 @@ defmodule Pleroma.Gun.Connections do
connect_opts
end
with stream <- API.connect(conn, connect_opts),
with {proxy_host, proxy_port} <- opts[:proxy],
open_opts <- Map.delete(opts, :tls_opts),
{:ok, conn} <- API.open(proxy_host, proxy_port, open_opts),
{:ok, _} <- API.await_up(conn),
stream <- API.connect(conn, connect_opts),
{:response, :fin, 200, _} <- API.await(conn, stream) do
{:ok, conn, true}
end
else
{:error, error} ->
{:error, error}