Skip to content

Commit 2afeb33

Browse files
Nadir Ghoulpgjones
authored andcommitted
Changing both encoding and decoding of the Host, from ascii to idna
1 parent 76fc847 commit 2afeb33

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wsproto/handshake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _process_connection_request( # noqa: MC0001
198198
if name == b"connection":
199199
connection_tokens = split_comma_header(value)
200200
elif name == b"host":
201-
host = value.decode("ascii")
201+
host = value.decode("idna")
202202
continue # Skip appending to headers
203203
elif name == b"sec-websocket-extensions":
204204
extensions = split_comma_header(value)
@@ -324,7 +324,7 @@ def _initiate_connection(self, request: Request) -> bytes:
324324
self._nonce = generate_nonce()
325325

326326
headers = [
327-
(b"Host", request.host.encode("ascii")),
327+
(b"Host", request.host.encode("idna")),
328328
(b"Upgrade", b"WebSocket"),
329329
(b"Connection", b"Upgrade"),
330330
(b"Sec-WebSocket-Key", self._nonce),

0 commit comments

Comments
 (0)