闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
423 B

  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