diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/http/gun.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/http/hackney.ex | 8 | ||||
-rw-r--r-- | lib/pleroma/http/middleware/follow_redirects.ex | 11 | ||||
-rw-r--r-- | lib/pleroma/http/proxy.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/pool/connections.ex | 10 |
5 files changed, 25 insertions, 14 deletions
diff --git a/lib/pleroma/http/gun.ex b/lib/pleroma/http/gun.ex index eeaa22c51..63724dc7f 100644 --- a/lib/pleroma/http/gun.ex +++ b/lib/pleroma/http/gun.ex @@ -7,7 +7,7 @@ defmodule Pleroma.HTTP.Gun do @spec options(keyword(), URI.t()) :: keyword() def options(opts \\ [], %URI{} = uri) do - merge_with_defaults() + merge_defaults_with_config() |> add_scheme_opts(uri) |> maybe_add_proxy() |> Keyword.merge(opts) @@ -16,7 +16,7 @@ defmodule Pleroma.HTTP.Gun do |> add_pool_alive_flag() end - defp merge_with_defaults do + defp merge_defaults_with_config do config = Config.get([:http, :adapter], []) defaults = [ @@ -59,7 +59,7 @@ defmodule Pleroma.HTTP.Gun do defp add_pool_alive_flag(opts) do pid = Process.whereis(opts[:pool]) - pool_alive? = !is_nil(pid) && Process.alive?(pid) + pool_alive? = is_pid(pid) && Process.alive?(pid) Keyword.put(opts, :pool_alive?, pool_alive?) end end diff --git a/lib/pleroma/http/hackney.ex b/lib/pleroma/http/hackney.ex index 782e8b5ae..ac616a8f6 100644 --- a/lib/pleroma/http/hackney.ex +++ b/lib/pleroma/http/hackney.ex @@ -1,14 +1,18 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP.Hackney do @spec options(keyword(), URI.t()) :: keyword() def options(opts \\ [], %URI{} = uri) do - merge_with_defaults() + merge_defaults_with_config() |> add_scheme_opts(uri) |> maybe_add_proxy() |> merge_with_incoming_opts(opts) |> add_pool_timeout() end - defp merge_with_defaults do + defp merge_defaults_with_config do config = Pleroma.Config.get([:http, :adapter], []) defaults = [ diff --git a/lib/pleroma/http/middleware/follow_redirects.ex b/lib/pleroma/http/middleware/follow_redirects.ex index bb22504c7..bed3ec9a0 100644 --- a/lib/pleroma/http/middleware/follow_redirects.ex +++ b/lib/pleroma/http/middleware/follow_redirects.ex @@ -1,13 +1,10 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP.Middleware.FollowRedirects do @moduledoc """ Follow 3xx redirects - ## Example - ``` - defmodule MyClient do - use Tesla - plug Tesla.Middleware.FollowRedirects, max_redirects: 3 # defaults to 5 - end - ``` ## Options - `:max_redirects` - limit number of redirects (default: `5`) """ diff --git a/lib/pleroma/http/proxy.ex b/lib/pleroma/http/proxy.ex index aa9964120..9d042b417 100644 --- a/lib/pleroma/http/proxy.ex +++ b/lib/pleroma/http/proxy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP.Proxy do require Logger diff --git a/lib/pleroma/pool/connections.ex b/lib/pleroma/pool/connections.ex index 49b68fc26..86bb00bc5 100644 --- a/lib/pleroma/pool/connections.ex +++ b/lib/pleroma/pool/connections.ex @@ -112,12 +112,18 @@ defmodule Pleroma.Pool.Connections do conn | last_reference: time, crf: crf, - conn_state: :active, used_by: [waiting | conn.used_by] } end) - state = put_in(state.conns[key], %{conn | conn: conn_pid, gun_state: :up, awaited_by: []}) + state = + put_in(state.conns[key], %{ + conn + | conn: conn_pid, + conn_state: :active, + gun_state: :up, + awaited_by: [] + }) {:noreply, state} end |