Sha256: 7f074d15e92b67a29be40da6e813500372d52c0e1cae5bd54dd1f814aa4761fa
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
module IndieWeb module Endpoints module Services class HttpRequestService # Defaults derived from Webmention specification examples # https://www.w3.org/TR/webmention/#limits-on-get-requests HTTP_CLIENT_OPTS = { follow: { max_hops: 20 }, headers: { accept: '*/*', user_agent: 'IndieWeb Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)' }, timeout_options: { connect_timeout: 5, read_timeout: 5 } }.freeze def initialize @client = HTTP::Client.new(HTTP_CLIENT_OPTS) end def get(uri) client.request(:get, uri) rescue HTTP::ConnectionError, HTTP::TimeoutError, HTTP::Redirector::TooManyRedirectsError => exception raise IndieWeb::Endpoints.const_get(exception.class.name.split('::').last), exception end private attr_accessor :client end end end end
Version data entries
5 entries across 5 versions & 1 rubygems