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

module HttpHelper
  USER_AGENT = "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"

  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
end