Sha256: 65b3cd7e221f3a734b364f1af9bdee1f9b3e7fa0b2ef2fb8ae2cd984da60c28a

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

module IndieWeb
  module Endpoints
    module Services
      class HttpRequestService
        HTTP_HEADERS_OPTS = {
          accept: '*/*',
          user_agent: 'IndieWeb Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)'
        }.freeze

        # HTTP options derived from Webmention specification examples
        # https://www.w3.org/TR/webmention/#limits-on-get-requests
        def self.get(uri)
          HTTP.follow(max_hops: 20).headers(HTTP_HEADERS_OPTS).timeout(connect: 5, read: 5).get(uri)
        rescue HTTP::ConnectionError,
               HTTP::TimeoutError,
               HTTP::Redirector::TooManyRedirectsError => exception
          raise IndieWeb::Endpoints.const_get(exception.class.name.split('::').last), exception
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
indieweb-endpoints-3.0.0 lib/indieweb/endpoints/services/http_request_service.rb