2020-02-11 08:12:57 +01:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-04 00:16:24 +01:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2020-02-11 08:12:57 +01:00
|
|
|
# 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
|
2020-09-07 14:47:43 +02:00
|
|
|
opts = Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
|
2020-02-11 08:12:57 +01:00
|
|
|
: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
|