http_helper.rb 423 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. module HttpHelper
  3. def http_client(options = {})
  4. timeout = { write: 10, connect: 10, read: 10 }.merge(options)
  5. HTTP.headers(user_agent: user_agent)
  6. .timeout(:per_operation, timeout)
  7. .follow
  8. end
  9. private
  10. def user_agent
  11. @user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"
  12. end
  13. end