Skip to content

[py] Return HTTP response reason when remote connection error occurs #15942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 26, 2025
Merged
8 changes: 4 additions & 4 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ def _request(self, method, url, body=None):
try:
if 300 <= statuscode < 304:
return self._request("GET", response.headers.get("location", None))
if 399 < statuscode <= 500:
if statuscode == 401:
return {"status": statuscode, "value": "Authorization Required"}
return {"status": statuscode, "value": str(statuscode) if not data else data.strip()}
if statuscode == 401:
return {"status": statuscode, "value": "Authorization Required"}
if statuscode >= 400:
return {"status": statuscode, "value": response.reason if not data else data.strip()}
content_type = []
if response.headers.get("Content-Type", None):
content_type = response.headers.get("Content-Type", None).split(";")
Expand Down
Loading