Skip to content

Commit 2d672e0

Browse files
authored
feat: handle non-utf8 charaters in response (#217)
* feat: handle non-utf8 charaters in response * linting
1 parent 8d407cc commit 2d672e0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

openevsehttp/__main__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ async def process_request(
106106
json=data,
107107
auth=auth,
108108
) as resp:
109-
message = await resp.text()
109+
try:
110+
message = await resp.text()
111+
except UnicodeDecodeError:
112+
_LOGGER.debug("Decoding error")
113+
message = await resp.read()
114+
message = message.decode(errors="replace")
115+
110116
try:
111117
message = json.loads(message)
112118
except ValueError:

pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ disable=
2525
too-many-public-methods,
2626
too-many-instance-attributes,
2727
too-many-branches,
28-
too-many-statements
28+
too-many-statements,
29+
too-many-lines
2930

3031
[REPORTS]
3132
score=no

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
PROJECT_DIR = Path(__file__).parent.resolve()
77
README_FILE = PROJECT_DIR / "README.md"
8-
VERSION = "0.1.48"
8+
VERSION = "0.1.49"
99

1010
setup(
1111
name="python-openevse-http",

0 commit comments

Comments
 (0)