Add user agent to fedsocket requests
This commit is contained in:
parent
6c052bd5b6
commit
26859c549c
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.FedSockets.OutgoingHandler do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
alias Pleroma.Application
|
||||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||||
alias Pleroma.Web.FedSockets
|
alias Pleroma.Web.FedSockets
|
||||||
alias Pleroma.Web.FedSockets.FedRegistry
|
alias Pleroma.Web.FedSockets.FedRegistry
|
||||||
|
@ -87,7 +88,10 @@ def initiate_connection(uri) do
|
||||||
|
|
||||||
with {:ok, conn_pid} <- :gun.open(to_charlist(host), port),
|
with {:ok, conn_pid} <- :gun.open(to_charlist(host), port),
|
||||||
{:ok, _} <- :gun.await_up(conn_pid),
|
{:ok, _} <- :gun.await_up(conn_pid),
|
||||||
reference <- :gun.get(conn_pid, to_charlist(path)),
|
reference <-
|
||||||
|
:gun.get(conn_pid, to_charlist(path), [
|
||||||
|
{'user-agent', to_charlist(Application.user_agent())}
|
||||||
|
]),
|
||||||
{:response, :fin, 204, _} <- :gun.await(conn_pid, reference),
|
{:response, :fin, 204, _} <- :gun.await(conn_pid, reference),
|
||||||
headers <- build_headers(uri),
|
headers <- build_headers(uri),
|
||||||
ref <- :gun.ws_upgrade(conn_pid, to_charlist(path), headers, %{silence_pings: false}) do
|
ref <- :gun.ws_upgrade(conn_pid, to_charlist(path), headers, %{silence_pings: false}) do
|
||||||
|
@ -132,7 +136,8 @@ defp build_headers(uri) do
|
||||||
{'date', date},
|
{'date', date},
|
||||||
{'digest', to_charlist(digest)},
|
{'digest', to_charlist(digest)},
|
||||||
{'content-length', to_charlist("#{shake_size}")},
|
{'content-length', to_charlist("#{shake_size}")},
|
||||||
{to_charlist("(request-target)"), to_charlist(shake)}
|
{to_charlist("(request-target)"), to_charlist(shake)},
|
||||||
|
{'user-agent', to_charlist(Application.user_agent())}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue