passing options for gun
This commit is contained in:
parent
7354d8958b
commit
c97979da77
@ -11,6 +11,20 @@ defmodule Pleroma.Gun.Connections do
|
||||
conns: %{domain() => conn()}
|
||||
}
|
||||
|
||||
@gun_keys [
|
||||
:connect_timeout,
|
||||
:http_opts,
|
||||
:http2_opts,
|
||||
:protocols,
|
||||
:retry,
|
||||
:retry_timeout,
|
||||
:trace,
|
||||
:transport,
|
||||
:tls_opts,
|
||||
:tcp_opts,
|
||||
:ws_opts
|
||||
]
|
||||
|
||||
defstruct conns: %{}
|
||||
|
||||
def start_link(name \\ __MODULE__) do
|
||||
@ -81,7 +95,8 @@ defmodule Pleroma.Gun.Connections do
|
||||
{:noreply, state}
|
||||
|
||||
nil ->
|
||||
{:ok, conn} = Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, opts)
|
||||
{:ok, conn} =
|
||||
Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, Map.take(opts, @gun_keys))
|
||||
|
||||
state =
|
||||
put_in(state.conns[key], %Pleroma.Gun.Conn{
|
||||
|
@ -62,7 +62,7 @@ defmodule Pleroma.HTTP do
|
||||
end
|
||||
|
||||
defp get_conn_for_gun(url, options) do
|
||||
case Pleroma.Gun.Connections.get_conn(url) do
|
||||
case Pleroma.Gun.Connections.get_conn(url, options) do
|
||||
nil ->
|
||||
options
|
||||
|
||||
@ -86,8 +86,15 @@ defmodule Pleroma.HTTP do
|
||||
host = uri.host |> to_charlist()
|
||||
|
||||
case uri.scheme do
|
||||
"https" -> options ++ [ssl: [server_name_indication: host]]
|
||||
_ -> options
|
||||
"https" ->
|
||||
tls_opts =
|
||||
Keyword.get(options, :tls_opts, [])
|
||||
|> Keyword.put(:server_name_indication, host)
|
||||
|
||||
Keyword.put(options, :tls_opts, tls_opts) ++ [ssl: [server_name_indication: host]]
|
||||
|
||||
_ ->
|
||||
options
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user