config: make sending the user agent configurable, disable sending the user agent in tests

This commit is contained in:
William Pitcock 2019-05-17 20:28:58 +00:00
parent d3b8cd342f
commit 290f5b2cfe
3 changed files with 10 additions and 1 deletions

View File

@ -192,6 +192,7 @@
# Configures http settings, upstream proxy etc. # Configures http settings, upstream proxy etc.
config :pleroma, :http, config :pleroma, :http,
proxy_url: nil, proxy_url: nil,
send_user_agent: true,
adapter: [ adapter: [
ssl_options: [ ssl_options: [
# We don't support TLS v1.3 yet # We don't support TLS v1.3 yet

View File

@ -63,6 +63,8 @@
config :pleroma, :http_security, report_uri: "https://endpoint.com" config :pleroma, :http_security, report_uri: "https://endpoint.com"
config :pleroma, :http, send_user_agent: false
rum_enabled = System.get_env("RUM_ENABLED") == "true" rum_enabled = System.get_env("RUM_ENABLED") == "true"
config :pleroma, :database, rum_enabled: rum_enabled config :pleroma, :database, rum_enabled: rum_enabled
IO.puts("RUM enabled: #{rum_enabled}") IO.puts("RUM enabled: #{rum_enabled}")

View File

@ -46,7 +46,13 @@ def url(request, u) do
""" """
@spec headers(map(), list(tuple)) :: map() @spec headers(map(), list(tuple)) :: map()
def headers(request, header_list) do def headers(request, header_list) do
header_list = header_list ++ [{"User-Agent", Pleroma.Application.user_agent()}] header_list =
if Pleroma.Config.get([:http, :send_user_agent]) do
header_list ++ [{"User-Agent", Pleroma.Application.user_agent()}]
else
header_list
end
Map.put_new(request, :headers, header_list) Map.put_new(request, :headers, header_list)
end end