diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-04-29 17:33:55 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-05-06 13:25:49 +0300 |
commit | da036b1793ef6018e01a2b04215deb4c9efcbe75 (patch) | |
tree | 244437854f6b3e94f0a6daa0c430a1f975b22d53 | |
parent | 3d0c943e5542d9a28fe5796fc4e4fff37cb71d7a (diff) | |
download | pleroma-da036b1793ef6018e01a2b04215deb4c9efcbe75.tar.gz |
clean up and copyright
-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 | ||||
-rw-r--r-- | test/http/middleware/follow_redirects_test.exs | 4 |
6 files changed, 29 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 diff --git a/test/http/middleware/follow_redirects_test.exs b/test/http/middleware/follow_redirects_test.exs index 533aff2c1..f3f4322ac 100644 --- a/test/http/middleware/follow_redirects_test.exs +++ b/test/http/middleware/follow_redirects_test.exs @@ -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.Middleware.FollowRedirectsTest do use ExUnit.Case |