square/okhttp — pull request #1185 by marshallpierce (2014-12-03 21:54:31+00:00)
Title: Allow configuring whether retries are allowed based on the request

Proposed solution to #1043: allow configuring when retries are allowed via `RetryPolicy#allowRetry(Request)`.

Implementations for "always yes", "always no", and whitelisting based on HTTP method are provided, but users can create their own.

This doesn't allow you to filter retries based on the type of error that was encountered. It's worth pondering how best to express configurability around retries based on information beyond the `Request` to make sure that we're not causing unnecessary API migration pain if we want to do that in the future. However, I suspect that it may be best to apply that in a separate mechanism so that one could easily mix'n'match a request-based policy with a IOException-based policy. Splitting policies up into interface-per-concern also means that if we *do* want to add IOException-based retry policies in a separate interface in the future, we can do so without perturbing this interface.