aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2018-12-06 15:57:56 +0000
committerkaniini <nenolod@gmail.com>2018-12-06 15:57:56 +0000
commitabead01ab6f5586e60d467d7efd0de560a97c5bd (patch)
tree8991de62733d2fed65ca271b420c5f35d2f7adcc /lib
parentb0adea30b38713e70039475acdd3defbef57171a (diff)
parenta09ed0f5afe6336763b47edab0c0d9a629a74ad0 (diff)
downloadpleroma-abead01ab6f5586e60d467d7efd0de560a97c5bd.tar.gz
Merge branch 'correct-and-improve-http-options' into 'develop'
Correct and improve http options See merge request pleroma/pleroma!505
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/http/connection.ex7
-rw-r--r--lib/pleroma/reverse_proxy.ex2
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex5
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex9
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex10
-rw-r--r--lib/pleroma/web/salmon/salmon.ex7
-rw-r--r--lib/pleroma/web/web_finger/web_finger.ex2
-rw-r--r--lib/pleroma/web/websub/websub.ex5
8 files changed, 20 insertions, 27 deletions
diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex
index 5e8f2aabd..db46f9e55 100644
--- a/lib/pleroma/http/connection.ex
+++ b/lib/pleroma/http/connection.ex
@@ -3,7 +3,12 @@ defmodule Pleroma.HTTP.Connection do
Connection for http-requests.
"""
- @hackney_options [pool: :default]
+ @hackney_options [
+ pool: :default,
+ timeout: 10000,
+ recv_timeout: 20000,
+ follow_redirect: true
+ ]
@adapter Application.get_env(:tesla, :adapter)
@doc """
diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex
index ad9dc82fe..4ca84152a 100644
--- a/lib/pleroma/reverse_proxy.ex
+++ b/lib/pleroma/reverse_proxy.ex
@@ -56,7 +56,7 @@ defmodule Pleroma.ReverseProxy do
@hackney Application.get_env(:pleroma, :hackney, :hackney)
@httpoison Application.get_env(:pleroma, :httpoison, HTTPoison)
- @default_hackney_options [{:follow_redirect, true}]
+ @default_hackney_options []
@inline_content_types [
"image/gif",
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 28da57a10..bf81d8039 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -772,10 +772,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
{:ok, %{body: body, status: code}} when code in 200..299 <-
@httpoison.get(
id,
- [Accept: "application/activity+json"],
- follow_redirect: true,
- timeout: 10000,
- recv_timeout: 20000
+ [{:Accept, "application/activity+json"}]
),
{:ok, data} <- Jason.decode(body),
:ok <- Transmogrifier.contain_origin_from_id(id, data) do
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index c9530c748..57de92dc0 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -1216,7 +1216,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
url = String.replace(api, "{{host}}", host) |> String.replace("{{user}}", user)
with {:ok, %{status: 200, body: body}} <-
- @httpoison.get(url, [], timeout: timeout, recv_timeout: timeout),
+ @httpoison.get(
+ url,
+ [],
+ adapter: [
+ timeout: timeout,
+ recv_timeout: timeout
+ ]
+ ),
{:ok, data} <- Jason.decode(body) do
data2 =
Enum.slice(data, 0, limit)
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index 67df354db..53d71440e 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -349,12 +349,7 @@ defmodule Pleroma.Web.OStatus do
{:ok, %{body: body, status: code}} when code in 200..299 <-
@httpoison.get(
url,
- [Accept: "application/atom+xml"],
- follow_redirect: true,
- adapter: [
- timeout: 10000,
- recv_timeout: 20000
- ]
+ [{:Accept, "application/atom+xml"}]
) do
Logger.debug("Got document from #{url}, handling...")
handle_incoming(body)
@@ -369,8 +364,7 @@ defmodule Pleroma.Web.OStatus do
Logger.debug("Trying to fetch #{url}")
with true <- String.starts_with?(url, "http"),
- {:ok, %{body: body}} <-
- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
+ {:ok, %{body: body}} <- @httpoison.get(url, []),
{:ok, atom_url} <- get_atom_url(body) do
fetch_activity_from_atom_url(atom_url)
else
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex
index 97251c05e..0e2cfddd0 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -162,12 +162,7 @@ defmodule Pleroma.Web.Salmon do
poster.(
salmon,
feed,
- [{"Content-Type", "application/magic-envelope+xml"}],
- adapter: [
- timeout: 10000,
- recv_timeout: 20000,
- pool: :default
- ]
+ [{"Content-Type", "application/magic-envelope+xml"}]
) do
Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end)
else
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index 99c65a6bf..0ff3b8b5f 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -221,7 +221,7 @@ defmodule Pleroma.Web.WebFinger do
def find_lrdd_template(domain) do
with {:ok, %{status: status, body: body}} when status in 200..299 <-
- @httpoison.get("http://#{domain}/.well-known/host-meta", [], follow_redirect: true) do
+ @httpoison.get("http://#{domain}/.well-known/host-meta", []) do
get_template_from_xml(body)
else
_ ->
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index 0761b5475..8cb07006f 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -264,11 +264,6 @@ defmodule Pleroma.Web.Websub do
[
{"Content-Type", "application/atom+xml"},
{"X-Hub-Signature", "sha1=#{signature}"}
- ],
- adapter: [
- timeout: 10000,
- recv_timeout: 20000,
- pool: :default
]
) do
Logger.info(fn -> "Pushed to #{callback}, code #{code}" end)