Skip to content

Commit

Permalink
[py] Remote connection throws resp statuscode when data is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Oct 15, 2024
1 parent c6e78d8 commit 890f130
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@ def _request(self, method, url, body=None):
data = response.data.decode("UTF-8")
LOGGER.debug("Remote response: status=%s | data=%s | headers=%s", response.status, data, response.headers)
try:
if statuscode == 401:
return {"status": statuscode, "value": "Authorization Required"}
if 300 <= statuscode < 304:
return self._request("GET", response.headers.get("location", None))
if 399 < statuscode <= 500:
return {"status": statuscode, "value": data}
return {"status": statuscode, "value": str(statuscode) 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

0 comments on commit 890f130

Please sign in to comment.