Skip to content

Commit 2b0d761

Browse files
AuroraTeadpgeorge
authored andcommitted
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'<BASE64-ENCODED_RANDOM_VALUE>'`. Signed-off-by: AuroraTea <[email protected]>
1 parent 00fc3fd commit 2b0d761

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

python-ecosys/aiohttp/aiohttp/aiohttp_ws.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _parse_frame_header(cls, header):
8686

8787
def _process_websocket_frame(self, opcode, payload):
8888
if opcode == self.TEXT:
89-
payload = payload.decode()
89+
payload = str(payload, "utf-8")
9090
elif opcode == self.BINARY:
9191
pass
9292
elif opcode == self.CLOSE:
@@ -143,7 +143,7 @@ async def handshake(self, uri, ssl, req):
143143
headers["Host"] = f"{uri.hostname}:{uri.port}"
144144
headers["Connection"] = "Upgrade"
145145
headers["Upgrade"] = "websocket"
146-
headers["Sec-WebSocket-Key"] = key
146+
headers["Sec-WebSocket-Key"] = str(key, "utf-8")
147147
headers["Sec-WebSocket-Version"] = "13"
148148
headers["Origin"] = f"{_http_proto}://{uri.hostname}:{uri.port}"
149149

python-ecosys/aiohttp/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
metadata(
22
description="HTTP client module for MicroPython asyncio module",
3-
version="0.0.2",
3+
version="0.0.3",
44
pypi="aiohttp",
55
)
66

0 commit comments

Comments
 (0)