Skip to content

Commit d50a168

Browse files
authored
[py] Return HTTP response reason when remote connection error occurs (#15942)
* [py] Return HTTP response reason when remote connection error occurs * [py] Remove f-string
1 parent 2d0bce8 commit d50a168

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/selenium/webdriver/remote/remote_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ def _request(self, method, url, body=None):
437437
try:
438438
if 300 <= statuscode < 304:
439439
return self._request("GET", response.headers.get("location", None))
440-
if 399 < statuscode <= 500:
441-
if statuscode == 401:
442-
return {"status": statuscode, "value": "Authorization Required"}
443-
return {"status": statuscode, "value": str(statuscode) if not data else data.strip()}
440+
if statuscode == 401:
441+
return {"status": statuscode, "value": "Authorization Required"}
442+
if statuscode >= 400:
443+
return {"status": statuscode, "value": response.reason if not data else data.strip()}
444444
content_type = []
445445
if response.headers.get("Content-Type", None):
446446
content_type = response.headers.get("Content-Type", None).split(";")

0 commit comments

Comments
 (0)