diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/http_helper.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/helpers/http_helper.rb b/app/helpers/http_helper.rb new file mode 100644 index 000000000..1e1ac8256 --- /dev/null +++ b/app/helpers/http_helper.rb @@ -0,0 +1,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 |