config :pleroma, :http,
proxy_url: nil,
send_user_agent: true,
+ user_agent: :default,
adapter: [
ssl_options: [
# Workaround for remote server certificate chain issues
* `dynamic_configuration`: Allow transferring configuration to DB with the subsequent customization from Admin api.
+## :http
+
+* `proxy_url`: an upstream proxy to fetch posts and/or media with, (default: `nil`)
+* `send_user_agent`: should we include a user agent with HTTP requests? (default: `true`)
+* `user_agent`: what user agent should we use? (default: `:default`), must be string or `:default`
+* `adapter`: array of hackney options
+
## Federation
### MRF policies
def repository, do: @repository
def user_agent do
- info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
- named_version() <> "; " <> info
+ case Pleroma.Config.get([:http, :user_agent], :default) do
+ :default ->
+ info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
+ named_version() <> "; " <> info
+
+ custom ->
+ custom
+ end
end
# See http://elixir-lang.org/docs/stable/elixir/Application.html
test "send pleroma user agent" do
Pleroma.Config.put([:http, :send_user_agent], true)
+ Pleroma.Config.put([:http, :user_agent], :default)
assert RequestBuilder.headers(%{}, []) == %{
headers: [{"User-Agent", Pleroma.Application.user_agent()}]
}
end
+
+ test "send custom user agent" do
+ Pleroma.Config.put([:http, :send_user_agent], true)
+ Pleroma.Config.put([:http, :user_agent], "totally-not-pleroma")
+
+ assert RequestBuilder.headers(%{}, []) == %{
+ headers: [{"User-Agent", "totally-not-pleroma"}]
+ }
+ end
end
describe "add_optional_params/3" do