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()}
|
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: %{}
|
defstruct conns: %{}
|
||||||
|
|
||||||
def start_link(name \\ __MODULE__) do
|
def start_link(name \\ __MODULE__) do
|
||||||
@ -81,7 +95,8 @@ defmodule Pleroma.Gun.Connections do
|
|||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
|
|
||||||
nil ->
|
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 =
|
state =
|
||||||
put_in(state.conns[key], %Pleroma.Gun.Conn{
|
put_in(state.conns[key], %Pleroma.Gun.Conn{
|
||||||
|
@ -62,7 +62,7 @@ defmodule Pleroma.HTTP do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp get_conn_for_gun(url, options) do
|
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 ->
|
nil ->
|
||||||
options
|
options
|
||||||
|
|
||||||
@ -86,8 +86,15 @@ defmodule Pleroma.HTTP do
|
|||||||
host = uri.host |> to_charlist()
|
host = uri.host |> to_charlist()
|
||||||
|
|
||||||
case uri.scheme do
|
case uri.scheme do
|
||||||
"https" -> options ++ [ssl: [server_name_indication: host]]
|
"https" ->
|
||||||
_ -> options
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user