lib/httpx/plugins/retries.rb in httpx-0.7.0 vs lib/httpx/plugins/retries.rb in httpx-0.8.0

- old
+ new

@@ -61,16 +61,22 @@ private def fetch_response(request, connections, options) response = super - retry_on = options.retry_on - - if response.is_a?(ErrorResponse) && + if response && request.retries.positive? && __repeatable_request?(request, options) && - __retryable_error?(response.error) && - (!retry_on || retry_on.call(response)) + ( + # rubocop:disable Style/MultilineTernaryOperator + options.retry_on ? + options.retry_on.call(response) : + ( + response.is_a?(ErrorResponse) && __retryable_error?(response.error) + ) + # rubocop:enable Style/MultilineTernaryOperator + ) + request.retries -= 1 log { "failed to get response, #{request.retries} tries to go..." } request.transition(:idle) retry_after = options.retry_after