Class: Micropub::Endpoint::Response
- Inherits:
-
Object
- Object
- Micropub::Endpoint::Response
- Defined in:
- lib/micropub/endpoint/response.rb
Constant Summary collapse
- HTTP_HEADERS_OPTS =
{ accept: '*/*', user_agent: 'Micropub Endpoint Discovery (https://rubygems.org/gems/micropub-endpoint)' }.freeze
Instance Method Summary collapse
-
#initialize(uri) ⇒ Response
constructor
A new instance of Response.
- #response ⇒ Object
Constructor Details
#initialize(uri) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 |
# File 'lib/micropub/endpoint/response.rb', line 9 def initialize(uri) raise ArgumentError, "uri must be an Addressable::URI (given #{uri.class.name})" unless uri.is_a?(Addressable::URI) @uri = uri end |
Instance Method Details
#response ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/micropub/endpoint/response.rb', line 15 def response @response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout( connect: 10, read: 10 ).get(@uri) rescue HTTP::ConnectionError => error raise ConnectionError, error rescue HTTP::TimeoutError => error raise TimeoutError, error rescue HTTP::Redirector::TooManyRedirectsError => error raise TooManyRedirectsError, error end |