Pass raise_for_status param through _client.request function
#113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Expected: Working Behavior
The
raise_for_statusparam inaiohttpcan be set on bothaiohttp.ClientSessionas well as individual HTTP method calls likesession.post().If you have
raise_for_statusset on both theClientSessionand thesession.post()method, then according to theaiohttpdocs, thesession.post()method ought to take precedent, and this is what we see when we useaiohttpdirectly withoutaiohttp-retry.Observed: Broken Behavior
When we pass in our own
client_sessionlike so:The retry client ignores the
raise_for_statusparam from thesession.post()and doesn't pass it to the inneraiohttp.ClientSessionas expected. As a result, we getExceptions thrown where we expect responses to return. See the tests section below.Fix
The fix is to pass
raise_for_statusthrough to the_request_funcmethod called from the originalaiohttp.ClientSession. That way theaiohttp.ClientSessioncan respect theraise_for_statuson thesession.post()Tests
Expected Behavior
request_raiseshould overridesession_raise, so anytimerequest_raiseisTrue, we should expect anErrorthrown, and anytimerequest_raiseisFalse, we should expect a normal status+text.No RetrySession-> Expected BehaviorTest
Results
RetrySession-> Broken BehaviorTest
Results
Caution
Testing: session_raise=True, request_raise=False, retries=3should not throw an error! Therequest_raiseshould take precedence over thesession_raiseRetrySessionwith this Fix Branch -> Expected BehaviorTest
(Same as before)
Results