Updated typing for WebsocketMessage.content

This commit is contained in:
Alexander Prinzhorn 2020-08-07 12:03:13 +02:00
parent fd4379aa2c
commit 2bb5f7b973
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Unreleased: mitmproxy next
* Add MsgPack content viewer (@tasn) * Add MsgPack content viewer (@tasn)
* Fix links to anticache docs in mitmweb and use HTTPS for links to documentation (@rugk) * Fix links to anticache docs in mitmweb and use HTTPS for links to documentation (@rugk)
* Updated typing for WebsocketMessage.content (@prinzhorn)
* --- TODO: add new PRs above this line --- * --- TODO: add new PRs above this line ---

View File

@ -1,6 +1,6 @@
import time import time
import queue import queue
from typing import List, Optional from typing import List, Optional, Union
from wsproto.frame_protocol import CloseReason from wsproto.frame_protocol import CloseReason
from wsproto.frame_protocol import Opcode from wsproto.frame_protocol import Opcode
@ -17,7 +17,7 @@ class WebSocketMessage(serializable.Serializable):
""" """
def __init__( def __init__(
self, type: int, from_client: bool, content: bytes, timestamp: Optional[float]=None, killed: bool=False self, type: int, from_client: bool, content: Union[bytes, str], timestamp: Optional[float]=None, killed: bool=False
) -> None: ) -> None:
self.type = Opcode(type) # type: ignore self.type = Opcode(type) # type: ignore
"""indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode).""" """indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode)."""