From 2b0d7610cef301881fea2c1e8994227367196093 Mon Sep 17 00:00:00 2001 From: AuroraTea <1352685369@qq.com> Date: Sun, 14 Apr 2024 16:35:52 +0800 Subject: [PATCH] aiohttp: Fix type of header's Sec-WebSocket-Key. The function `binascii.b2a_base64()` returns a `bytes`, but here needs a string. Otherwise, the value of `Sec-WebSocket-Key` in the headers will be `b''`. Signed-off-by: AuroraTea <1352685369@qq.com> --- python-ecosys/aiohttp/aiohttp/aiohttp_ws.py | 4 ++-- python-ecosys/aiohttp/manifest.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py index e5575a11..07d83373 100644 --- a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py +++ b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py @@ -86,7 +86,7 @@ class WebSocketClient: def _process_websocket_frame(self, opcode, payload): if opcode == self.TEXT: - payload = payload.decode() + payload = str(payload, "utf-8") elif opcode == self.BINARY: pass elif opcode == self.CLOSE: @@ -143,7 +143,7 @@ class WebSocketClient: headers["Host"] = f"{uri.hostname}:{uri.port}" headers["Connection"] = "Upgrade" headers["Upgrade"] = "websocket" - headers["Sec-WebSocket-Key"] = key + headers["Sec-WebSocket-Key"] = str(key, "utf-8") headers["Sec-WebSocket-Version"] = "13" headers["Origin"] = f"{_http_proto}://{uri.hostname}:{uri.port}" diff --git a/python-ecosys/aiohttp/manifest.py b/python-ecosys/aiohttp/manifest.py index 9cb2ef50..748970e5 100644 --- a/python-ecosys/aiohttp/manifest.py +++ b/python-ecosys/aiohttp/manifest.py @@ -1,6 +1,6 @@ metadata( description="HTTP client module for MicroPython asyncio module", - version="0.0.2", + version="0.0.3", pypi="aiohttp", )