mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 08:16:16 +00:00
Merge branch 'correct-and-improve-http-options' into 'develop'
Correct and improve http options See merge request pleroma/pleroma!505
This commit is contained in:
commit
abead01ab6
|
@ -3,7 +3,12 @@ defmodule Pleroma.HTTP.Connection do
|
||||||
Connection for http-requests.
|
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)
|
@adapter Application.get_env(:tesla, :adapter)
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -56,7 +56,7 @@ defmodule Pleroma.ReverseProxy do
|
||||||
@hackney Application.get_env(:pleroma, :hackney, :hackney)
|
@hackney Application.get_env(:pleroma, :hackney, :hackney)
|
||||||
@httpoison Application.get_env(:pleroma, :httpoison, HTTPoison)
|
@httpoison Application.get_env(:pleroma, :httpoison, HTTPoison)
|
||||||
|
|
||||||
@default_hackney_options [{:follow_redirect, true}]
|
@default_hackney_options []
|
||||||
|
|
||||||
@inline_content_types [
|
@inline_content_types [
|
||||||
"image/gif",
|
"image/gif",
|
||||||
|
|
|
@ -772,10 +772,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
||||||
@httpoison.get(
|
@httpoison.get(
|
||||||
id,
|
id,
|
||||||
[Accept: "application/activity+json"],
|
[{:Accept, "application/activity+json"}]
|
||||||
follow_redirect: true,
|
|
||||||
timeout: 10000,
|
|
||||||
recv_timeout: 20000
|
|
||||||
),
|
),
|
||||||
{:ok, data} <- Jason.decode(body),
|
{:ok, data} <- Jason.decode(body),
|
||||||
:ok <- Transmogrifier.contain_origin_from_id(id, data) do
|
:ok <- Transmogrifier.contain_origin_from_id(id, data) do
|
||||||
|
|
|
@ -1216,7 +1216,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
url = String.replace(api, "{{host}}", host) |> String.replace("{{user}}", user)
|
url = String.replace(api, "{{host}}", host) |> String.replace("{{user}}", user)
|
||||||
|
|
||||||
with {:ok, %{status: 200, body: body}} <-
|
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
|
{:ok, data} <- Jason.decode(body) do
|
||||||
data2 =
|
data2 =
|
||||||
Enum.slice(data, 0, limit)
|
Enum.slice(data, 0, limit)
|
||||||
|
|
|
@ -349,12 +349,7 @@ defmodule Pleroma.Web.OStatus do
|
||||||
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
||||||
@httpoison.get(
|
@httpoison.get(
|
||||||
url,
|
url,
|
||||||
[Accept: "application/atom+xml"],
|
[{:Accept, "application/atom+xml"}]
|
||||||
follow_redirect: true,
|
|
||||||
adapter: [
|
|
||||||
timeout: 10000,
|
|
||||||
recv_timeout: 20000
|
|
||||||
]
|
|
||||||
) do
|
) do
|
||||||
Logger.debug("Got document from #{url}, handling...")
|
Logger.debug("Got document from #{url}, handling...")
|
||||||
handle_incoming(body)
|
handle_incoming(body)
|
||||||
|
@ -369,8 +364,7 @@ defmodule Pleroma.Web.OStatus do
|
||||||
Logger.debug("Trying to fetch #{url}")
|
Logger.debug("Trying to fetch #{url}")
|
||||||
|
|
||||||
with true <- String.starts_with?(url, "http"),
|
with true <- String.starts_with?(url, "http"),
|
||||||
{:ok, %{body: body}} <-
|
{:ok, %{body: body}} <- @httpoison.get(url, []),
|
||||||
@httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
|
|
||||||
{:ok, atom_url} <- get_atom_url(body) do
|
{:ok, atom_url} <- get_atom_url(body) do
|
||||||
fetch_activity_from_atom_url(atom_url)
|
fetch_activity_from_atom_url(atom_url)
|
||||||
else
|
else
|
||||||
|
|
|
@ -162,12 +162,7 @@ defmodule Pleroma.Web.Salmon do
|
||||||
poster.(
|
poster.(
|
||||||
salmon,
|
salmon,
|
||||||
feed,
|
feed,
|
||||||
[{"Content-Type", "application/magic-envelope+xml"}],
|
[{"Content-Type", "application/magic-envelope+xml"}]
|
||||||
adapter: [
|
|
||||||
timeout: 10000,
|
|
||||||
recv_timeout: 20000,
|
|
||||||
pool: :default
|
|
||||||
]
|
|
||||||
) do
|
) do
|
||||||
Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end)
|
Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end)
|
||||||
else
|
else
|
||||||
|
|
|
@ -221,7 +221,7 @@ defmodule Pleroma.Web.WebFinger do
|
||||||
|
|
||||||
def find_lrdd_template(domain) do
|
def find_lrdd_template(domain) do
|
||||||
with {:ok, %{status: status, body: body}} when status in 200..299 <-
|
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)
|
get_template_from_xml(body)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
|
|
|
@ -264,11 +264,6 @@ defmodule Pleroma.Web.Websub do
|
||||||
[
|
[
|
||||||
{"Content-Type", "application/atom+xml"},
|
{"Content-Type", "application/atom+xml"},
|
||||||
{"X-Hub-Signature", "sha1=#{signature}"}
|
{"X-Hub-Signature", "sha1=#{signature}"}
|
||||||
],
|
|
||||||
adapter: [
|
|
||||||
timeout: 10000,
|
|
||||||
recv_timeout: 20000,
|
|
||||||
pool: :default
|
|
||||||
]
|
]
|
||||||
) do
|
) do
|
||||||
Logger.info(fn -> "Pushed to #{callback}, code #{code}" end)
|
Logger.info(fn -> "Pushed to #{callback}, code #{code}" end)
|
||||||
|
|
Loading…
Reference in a new issue