Class: RaptorIO::Protocol::HTTP::Request::Manipulators::Authenticator
- Inherits:
-
RaptorIO::Protocol::HTTP::Request::Manipulator
- Object
- RaptorIO::Protocol::HTTP::Request::Manipulator
- RaptorIO::Protocol::HTTP::Request::Manipulators::Authenticator
- Defined in:
- lib/raptor-io/protocol/http/request/manipulators/authenticator.rb
Overview
Implements automatic HTTP authentication.
Instance Attribute Summary
Attributes inherited from RaptorIO::Protocol::HTTP::Request::Manipulator
Instance Method Summary collapse
Methods inherited from RaptorIO::Protocol::HTTP::Request::Manipulator
#datastore, #delegate, inherited, #initialize, #shortname, shortname, #validate_options, validate_options, validate_options!
Constructor Details
This class inherits a constructor from RaptorIO::Protocol::HTTP::Request::Manipulator
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/raptor-io/protocol/http/request/manipulators/authenticator.rb', line 29 def run datastore[:tries] ||= 0 return if skip? callbacks = request.callbacks.dup request.clear_callbacks # We need to block until authentication is complete, that's why we requeue # and run. requeue request.on_complete do |response| auth_type = type( response ) if !failed? && response.code == 401 && supported?( auth_type ) retry_with_auth( auth_type, response ) else request.callbacks = callbacks request.handle_response response request.clear_callbacks end end client.run end |