aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-01-30 08:16:31 +0000
committerlambda <pleromagit@rogerbraun.net>2018-01-30 08:16:31 +0000
commit2f23ae5b684a363b6090a45c4b1b9685c9ed614a (patch)
treeab91ff8fbb1101d05378a5e0e3e6156dce9ae68c /lib
parent189e9d63bc462fe5c0f97d70ffd4bac54aeeae05 (diff)
parent066fe1a697286e38c9e9ef7f2c273c4e7a50ffdc (diff)
downloadpleroma-2f23ae5b684a363b6090a45c4b1b9685c9ed614a.tar.gz
Merge branch 'pr-upstream-http-proxy' into 'develop'
Pr upstream http proxy See merge request pleroma/pleroma!43
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/http/http.ex14
-rw-r--r--lib/pleroma/web/media_proxy/controller.ex4
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex
new file mode 100644
index 000000000..8b8a82353
--- /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, nil)
+ case proxy do
+ nil -> options
+ _ -> options ++ [proxy: proxy]
+ end
+ end
+
+end
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),