Don't override user-agent header if it's been set

This commit is contained in:
Roman Chvanikov 2020-08-01 10:04:25 +03:00
parent a1a43f39dc
commit 4bf44b7d65

View file

@ -34,10 +34,12 @@ def url(request, u), do: %{request | url: u}
@spec headers(Request.t(), Request.headers()) :: Request.t() @spec headers(Request.t(), Request.headers()) :: Request.t()
def headers(request, headers) do def headers(request, headers) do
headers_list = headers_list =
if Pleroma.Config.get([:http, :send_user_agent]) do with true <- Pleroma.Config.get([:http, :send_user_agent]),
nil <- Enum.find(headers, fn {key, _val} -> String.downcase(key) == "user-agent" end) do
[{"user-agent", Pleroma.Application.user_agent()} | headers] [{"user-agent", Pleroma.Application.user_agent()} | headers]
else else
headers _ ->
headers
end end
%{request | headers: headers_list} %{request | headers: headers_list}