Skip to content

Commit 84b4f32

Browse files
committed
Accept bytes alongside string as path argument in initiate_upgrade_connection
Thanks to @vxgmichel for pointing this out and the patch.
1 parent 7d50c07 commit 84b4f32

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/wsproto/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
A WebSocket implementation.
66
"""
7-
from typing import Generator, Optional
7+
from typing import Generator, Optional, Union
88

99
from .connection import Connection, ConnectionState, ConnectionType
1010
from .events import Event
@@ -40,7 +40,9 @@ def state(self) -> ConnectionState:
4040
return self.handshake.state
4141
return self.connection.state
4242

43-
def initiate_upgrade_connection(self, headers: Headers, path: str) -> None:
43+
def initiate_upgrade_connection(
44+
self, headers: Headers, path: Union[bytes, str]
45+
) -> None:
4446
self.handshake.initiate_upgrade_connection(headers, path)
4547

4648
def send(self, event: Event) -> bytes:

src/wsproto/handshake.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def connection(self) -> Optional[Connection]:
6969
"""
7070
return self._connection
7171

72-
def initiate_upgrade_connection(self, headers: Headers, path: str) -> None:
72+
def initiate_upgrade_connection(
73+
self, headers: Headers, path: Union[bytes, str]
74+
) -> None:
7375
"""Initiate an upgrade connection.
7476
7577
This should be used if the request has already be received and

0 commit comments

Comments
 (0)