X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fhttp%2Fhttp.ex;h=26214ef3feca94c4af8e12b2b07c832b0a3c0c7d;hb=b57913b13ad07cfaa345f7d1e964cd37e5545aa5;hp=3c02565757622e30748a891519fbfc7c11cd570e;hpb=4944498133d4a945650201226808b1f09d355014;p=akkoma diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 3c0256575..26214ef3f 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP do @moduledoc """ @@ -6,6 +10,8 @@ defmodule Pleroma.HTTP do alias Pleroma.HTTP.Connection alias Pleroma.HTTP.RequestBuilder, as: Builder + @type t :: __MODULE__ + @doc """ Builds and perform http request. @@ -24,6 +30,9 @@ defmodule Pleroma.HTTP do options = process_request_options(options) |> process_sni_options(url) + |> process_adapter_options() + + params = Keyword.get(options, :params, []) %{} |> Builder.method(method) @@ -31,6 +40,7 @@ defmodule Pleroma.HTTP do |> Builder.opts(options) |> Builder.url(url) |> Builder.add_param(:body, :body, body) + |> Builder.add_param(:query, :query, params) |> Enum.into([]) |> (&Tesla.request(Connection.new(), &1)).() end @@ -47,10 +57,15 @@ defmodule Pleroma.HTTP do end end + def process_adapter_options(options) do + adapter_options = Pleroma.Config.get([:http, :adapter], []) + + options ++ [adapter: adapter_options] + end + def process_request_options(options) do config = Application.get_env(:pleroma, :http, []) proxy = Keyword.get(config, :proxy_url, nil) - options = options ++ [adapter: [pool: :default]] case proxy do nil -> options