mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-14 03:16:28 +10:00
network_handler.py: Use raise_for_status to detect error
This commit is contained in:
@@ -65,17 +65,15 @@ class NetworkUtilities:
|
|||||||
|
|
||||||
def validate_link(self) -> bool:
|
def validate_link(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Check for 404 error
|
Check for error
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if link is valid, False otherwise
|
bool: True if link is valid, False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
response = SESSION.head(self.url, timeout=5, allow_redirects=True)
|
response = SESSION.head(self.url, timeout=5, allow_redirects=True)
|
||||||
if response.status_code == 404:
|
response.raise_for_status()
|
||||||
return False
|
return True
|
||||||
else:
|
|
||||||
return True
|
|
||||||
except (
|
except (
|
||||||
requests.exceptions.Timeout,
|
requests.exceptions.Timeout,
|
||||||
requests.exceptions.TooManyRedirects,
|
requests.exceptions.TooManyRedirects,
|
||||||
|
|||||||
Reference in New Issue
Block a user