# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxy.Client.Tesla do
@behaviour Pleroma.ReverseProxy.Client
- alias Pleroma.Gun.ConnectionPool
-
@type headers() :: [{String.t(), String.t()}]
@type status() :: pos_integer()
if is_map(response.body) and method != :head do
{:ok, response.status, response.headers, response.body}
else
- conn_pid = response.opts[:adapter][:conn]
- ConnectionPool.release_conn(conn_pid)
{:ok, response.status, response.headers}
end
else
@impl true
@spec stream_body(map()) ::
{:ok, binary(), map()} | {:error, atom() | String.t()} | :done | no_return()
- def stream_body(%{pid: pid, fin: true}) do
- ConnectionPool.release_conn(pid)
+ def stream_body(%{pid: _pid, fin: true}) do
:done
end
@impl true
@spec close(map) :: :ok | no_return()
- def close(%{pid: pid}) do
- ConnectionPool.release_conn(pid)
+ def close(%{pid: _pid}) do
+ :ok
end
defp check_adapter do
adapter = Application.get_env(:tesla, :adapter)
- unless adapter == Tesla.Adapter.Gun do
- raise "#{adapter} doesn't support reading body in chunks"
- end
-
adapter
end
end