implement retry logic

Note, each type of retry (connect, read, redirect etc) will be retried for the
maximum of the retry type, and the total number of retries. So if you specify
2 connect retries, but 4 total retries, a total of 4 connection errors will be
retried before giving up and raising a MaxRetryError.