Skip to content

Commit

Permalink
Make status_code checks more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Dec 4, 2023
1 parent 4893c21 commit a523e88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion redbot/resource/active_check/etag_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def modify_request_headers(
return base_headers

def preflight(self) -> bool:
if 300 <= self.base.response.status_code <= 399:
if (
self.base.response.status_code
and 300 <= self.base.response.status_code <= 399
):
return False
etag = self.base.response.headers.parsed.get("etag", None)
if etag:
Expand Down
5 changes: 4 additions & 1 deletion redbot/resource/active_check/lm_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def modify_request_headers(
return base_headers

def preflight(self) -> bool:
if 300 <= self.base.response.status_code <= 399:
if (
self.base.response.status_code
and 300 <= self.base.response.status_code <= 399
):
return False
if self.base.response.headers.parsed.get("last-modified", None):
return True
Expand Down
5 changes: 4 additions & 1 deletion redbot/resource/active_check/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def modify_request_headers(
return base_headers

def preflight(self) -> bool:
if 300 <= self.base.response.status_code <= 399:
if (
self.base.response.status_code
and 300 <= self.base.response.status_code <= 399
):
return False
if self.base.response.status_code == 206:
return False
Expand Down

0 comments on commit a523e88

Please sign in to comment.