Class: Excon::Middleware::Idempotent
- Defined in:
- lib/excon/middlewares/idempotent.rb
Instance Method Summary collapse
Methods inherited from Base
#initialize, #request_call, #response_call
Constructor Details
This class inherits a constructor from Excon::Middleware::Base
Instance Method Details
#error_call(datum) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/excon/middlewares/idempotent.rb', line 4 def error_call(datum) if datum[:idempotent] && [Excon::Errors::Timeout, Excon::Errors::SocketError, Excon::Errors::HTTPStatusError].any? {|ex| datum[:error].kind_of?(ex) } && datum[:retries_remaining] > 1 # reduces remaining retries, reset connection, and restart request_call datum[:retries_remaining] -= 1 connection = datum.delete(:connection) datum.reject! {|key, _| !VALID_REQUEST_KEYS.include?(key) } connection.request(datum) else @stack.error_call(datum) end end |