Add user agent to fedsocket requests
authorMark Felder <feld@FreeBSD.org>
Fri, 18 Sep 2020 22:49:15 +0000 (17:49 -0500)
committerMark Felder <feld@FreeBSD.org>
Sat, 19 Sep 2020 12:26:46 +0000 (07:26 -0500)
lib/pleroma/web/fed_sockets/outgoing_handler.ex

index 6ddef17fe43965275d79b86564f17333ce8c2e4a..3ff4a85e3aefd4cd530a3360d73ba00ed9f633b8 100644 (file)
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.FedSockets.OutgoingHandler do
 
   require Logger
 
+  alias Pleroma.Application
   alias Pleroma.Web.ActivityPub.InternalFetchActor
   alias Pleroma.Web.FedSockets
   alias Pleroma.Web.FedSockets.FedRegistry
@@ -87,7 +88,10 @@ defmodule Pleroma.Web.FedSockets.OutgoingHandler do
 
     with {:ok, conn_pid} <- :gun.open(to_charlist(host), port),
          {: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),
          headers <- build_headers(uri),
          ref <- :gun.ws_upgrade(conn_pid, to_charlist(path), headers, %{silence_pings: false}) do
@@ -132,7 +136,8 @@ defmodule Pleroma.Web.FedSockets.OutgoingHandler do
       {'date', date},
       {'digest', to_charlist(digest)},
       {'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