This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-04-27 05:42:22 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module HttpHelper
|
|
|
|
def http_client(options = {})
|
|
|
|
timeout = { write: 10, connect: 10, read: 10 }.merge(options)
|
|
|
|
|
2017-05-04 17:23:01 -07:00
|
|
|
HTTP.headers(user_agent: user_agent)
|
2017-04-27 05:42:22 -07:00
|
|
|
.timeout(:per_operation, timeout)
|
|
|
|
.follow
|
|
|
|
end
|
2017-05-04 17:23:01 -07:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def user_agent
|
|
|
|
@user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"
|
|
|
|
end
|
2017-04-27 05:42:22 -07:00
|
|
|
end
|