Class: AuthorizationEndpoint::Response
- Inherits:
-
Object
- Object
- AuthorizationEndpoint::Response
- Defined in:
- lib/authorization_endpoint/response.rb
Constant Summary collapse
- HTTP_HEADERS_OPTS =
{ accept: '*/*', user_agent: 'Authorization Endpoint Discovery (https://rubygems.org/gems/authorization-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.
8 9 10 11 12 |
# File 'lib/authorization_endpoint/response.rb', line 8 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
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/authorization_endpoint/response.rb', line 14 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 |