Skip to content

Commit

Permalink
Reject throttling status code (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pliner committed Feb 9, 2022
1 parent 286b701 commit 008a5ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions aio_request/response_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ def classify(self, response: Response) -> ResponseVerdict:
return ResponseVerdict.REJECT
if response.status == 408:
return ResponseVerdict.REJECT
if response.status == 429:
return ResponseVerdict.REJECT
return ResponseVerdict.ACCEPT
4 changes: 2 additions & 2 deletions tests/test_response_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
[
(408, None, aio_request.ResponseVerdict.REJECT),
(400, None, aio_request.ResponseVerdict.ACCEPT),
(429, None, aio_request.ResponseVerdict.ACCEPT),
(429, {429: aio_request.ResponseVerdict.REJECT}, aio_request.ResponseVerdict.REJECT),
(429, None, aio_request.ResponseVerdict.REJECT),
(429, {429: aio_request.ResponseVerdict.ACCEPT}, aio_request.ResponseVerdict.ACCEPT),
],
)
def test_default_response_classifier(
Expand Down

0 comments on commit 008a5ac

Please sign in to comment.