Hackney interferes with out URI encoding and implements older RFC 2396 instead of RFC 3986 which we and Elixir implement. As an example "'" and "!" will get encoded by it and cause problems with our MediaProxy making unexpected 302 redirects. If an admin supplies a different function via *.secret.exs, we don't override it. https://github.com/benoitc/hackney/issues/399
29 lines
726 B
Elixir
29 lines
726 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.ReverseProxy.Client.Hackney do
|
|
@behaviour Pleroma.ReverseProxy.Client
|
|
|
|
@impl true
|
|
def request(method, url, headers, body, opts \\ []) do
|
|
opts =
|
|
Keyword.put_new(opts, :path_encode_fun, fn path ->
|
|
path
|
|
end)
|
|
|
|
:hackney.request(method, url, headers, body, opts)
|
|
end
|
|
|
|
@impl true
|
|
def stream_body(ref) do
|
|
case :hackney.stream_body(ref) do
|
|
:done -> :done
|
|
{:ok, data} -> {:ok, data, ref}
|
|
{:error, error} -> {:error, error}
|
|
end
|
|
end
|
|
|
|
@impl true
|
|
def close(ref), do: :hackney.close(ref)
|
|
end
|