Motivations
Right now, RetryPolicy only knows how many times a request has failed, but it doesn't have any other context about the request+response in question. It would be nice to customize the retry policy based on the value of request and response.
Solution
Add some parameters to RetryPolicy::should_retry, at a minimum:
url of the request
StatusCode of the response
And then maybe there should be more, but I think these are the most important.
Alternatives
Writing my own retry middleware.