about summary refs log tree commit diff
path: root/app/helpers/http_helper.rb
blob: e39a52da01fe451d3efe02f6a4afd94a6f2a786d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module HttpHelper
  def http_client(options = {})
    timeout = { write: 10, connect: 10, read: 10 }.merge(options)

    HTTP.headers(user_agent: user_agent)
        .timeout(:per_operation, timeout)
        .follow
  end

  private

  def user_agent
    @user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"
  end
end