Adds a retry_if option to the retry middleware

retry_if allows users to provide a block that
will receive the env and exception objects
and should decide if the call should be retried
or not.

Fixes #298.
Retry only if the method is idempotent

Only run retries if the method is known to be
idempotent. If it isn't, switch to use the retry_if
block to make the final decision, if it is known to
be idempotent allow it to be retried by default.
Merge pull request #340 from mauricio/issue-298

Retry only HTTP methods known to be idempotent

User can optionally configure other methods.

Fixes #298