Sha256: f8f5d92308ab8543ff8096e865d000a081d1a3633f51451822493fe92d911320

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

module Excon
  module Middleware
    class Idempotent < Excon::Middleware::Base
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excon-0.27.4 lib/excon/middlewares/idempotent.rb
excon-0.27.3 lib/excon/middlewares/idempotent.rb
excon-0.27.1 lib/excon/middlewares/idempotent.rb
excon-0.27.0 lib/excon/middlewares/idempotent.rb