Merge pull request #4134 from Prinzhorn/websocket_content_typing

Updated typing for WebsocketMessage.content
This commit is contained in:
Maximilian Hils 2020-08-07 12:31:02 +02:00 committed by GitHub
commit 029b077e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)."""