From 5ddd15d794bc8f9be3ca073589bab1f92b001cce Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 30 Dec 2017 11:35:53 -0500 Subject: make httppoison use configurable http proxy --- lib/pleroma/http/http.ex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/pleroma/http/http.ex (limited to 'lib') diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex new file mode 100644 index 000000000..31135411c --- /dev/null +++ b/lib/pleroma/http/http.ex @@ -0,0 +1,14 @@ + +defmodule Pleroma.HTTP do + use HTTPoison.Base + + def process_request_options(options) do + config = Application.get_env(:pleroma, :http, []) + proxy = Keyword.get(config, :proxy_url, "") + case proxy do + "" -> options + _ -> options ++ [proxy: proxy] + end + end + +end -- cgit v1.2.3 From 1e185b9301ec85cd2aaeb1faf075aaa86f733373 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 31 Dec 2017 09:25:00 -0500 Subject: apply proxy settings to media_proxy --- lib/pleroma/web/media_proxy/controller.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/media_proxy/controller.ex b/lib/pleroma/web/media_proxy/controller.ex index 560a65353..9327e7253 100644 --- a/lib/pleroma/web/media_proxy/controller.ex +++ b/lib/pleroma/web/media_proxy/controller.ex @@ -2,6 +2,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do use Pleroma.Web, :controller require Logger + @httpoison Application.get_env(:pleroma, :httpoison) + @max_body_length 25 * 1048576 @cache_control %{ @@ -29,7 +31,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do defp proxy_request(link) do headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}] - options = [:insecure, {:follow_redirect, true}] + options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}]) with \ {:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options), headers = Enum.into(headers, Map.new), -- cgit v1.2.3 From 066fe1a697286e38c9e9ef7f2c273c4e7a50ffdc Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 29 Jan 2018 10:06:16 -0500 Subject: use nil instead of empty string --- lib/pleroma/http/http.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 31135411c..8b8a82353 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -4,9 +4,9 @@ defmodule Pleroma.HTTP do def process_request_options(options) do config = Application.get_env(:pleroma, :http, []) - proxy = Keyword.get(config, :proxy_url, "") + proxy = Keyword.get(config, :proxy_url, nil) case proxy do - "" -> options + nil -> options _ -> options ++ [proxy: proxy] end end -- cgit v1.2.3