From 37d4e9b618febe13c03dd4270df62dbaf57501ce Mon Sep 17 00:00:00 2001 From: Yevhenii Vaskivskyi Date: Tue, 31 Oct 2023 19:20:35 +0100 Subject: [PATCH] Ignore UnicodeDecodeError on reading content (#323) --- asusrouter/connection.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asusrouter/connection.py b/asusrouter/connection.py index 7ad20c2..3a779e7 100644 --- a/asusrouter/connection.py +++ b/asusrouter/connection.py @@ -274,7 +274,11 @@ async def _make_post_request( resp_headers = response.headers # Read the response - resp_content = await response.text() + try: + resp_content = await response.text() + except UnicodeDecodeError: + _LOGGER.debug("Cannot decode response. Will ignore errors") + resp_content = await response.text(errors="ignore") # Return the response return (resp_status, resp_headers, resp_content)