Skip to content

Commit

Permalink
Returns the http response when giving up on retrying by status (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiokr authored and iMacTia committed Mar 24, 2018
1 parent 0989bf1 commit 0aebd35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/faraday/request/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def call(env)
end
end

raise unless exception.is_a?(Faraday::Error::RetriableResponse)
if exception.is_a?(Faraday::Error::RetriableResponse)
exception.response
else
raise
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion test/middleware/retry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ def test_should_rewind_files_on_retry

def test_should_retry_retriable_response
params = { status: 429 }
conn(:max => 1, :retry_statuses => 429).get("/throttled", params)
response = conn(:max => 1, :retry_statuses => 429).get("/throttled", params)

assert_equal 2, @times_called
assert_equal 429, response.status
end

def test_should_not_retry_non_retriable_response
Expand Down

0 comments on commit 0aebd35

Please sign in to comment.