http(hackney): disable adapter redirects by default
Hackney 1.25.x has redirect handling issues behind CONNECT proxies and with pools. Disable hackney-level redirects and rely on Tesla.Middleware.FollowRedirects instead. Also default to with_body: true so redirects can be followed reliably.
This commit is contained in:
parent
e091349718
commit
ef0f04ca48
2 changed files with 11 additions and 2 deletions
|
|
@ -6,8 +6,9 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|
||||||
@behaviour Pleroma.HTTP.AdapterHelper
|
@behaviour Pleroma.HTTP.AdapterHelper
|
||||||
|
|
||||||
@defaults [
|
@defaults [
|
||||||
follow_redirect: true,
|
follow_redirect: false,
|
||||||
force_redirect: true
|
force_redirect: false,
|
||||||
|
with_body: true
|
||||||
]
|
]
|
||||||
|
|
||||||
@spec options(keyword(), URI.t()) :: keyword()
|
@spec options(keyword(), URI.t()) :: keyword()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
|
||||||
describe "options/2" do
|
describe "options/2" do
|
||||||
setup do: clear_config([:http, :adapter], a: 1, b: 2)
|
setup do: clear_config([:http, :adapter], a: 1, b: 2)
|
||||||
|
|
||||||
|
test "uses redirect-safe defaults", %{uri: uri} do
|
||||||
|
opts = Hackney.options([], uri)
|
||||||
|
|
||||||
|
assert opts[:follow_redirect] == false
|
||||||
|
assert opts[:force_redirect] == false
|
||||||
|
assert opts[:with_body] == true
|
||||||
|
end
|
||||||
|
|
||||||
test "add proxy and opts from config", %{uri: uri} do
|
test "add proxy and opts from config", %{uri: uri} do
|
||||||
opts = Hackney.options([proxy: "localhost:8123"], uri)
|
opts = Hackney.options([proxy: "localhost:8123"], uri)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue