aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/websocket.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2018-01-01 11:16:52 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2018-01-01 13:34:21 +0100
commit4495562f86de5c3f41a0cf1616c08e74f45b20dd (patch)
tree03ecba1ec2f1c0c900a75b25cda1661ef2d92b51 /mitmproxy/websocket.py
parenteb53cc7ed26f451855755164f061ea9f49014f8d (diff)
downloadmitmproxy-4495562f86de5c3f41a0cf1616c08e74f45b20dd.tar.gz
mitmproxy-4495562f86de5c3f41a0cf1616c08e74f45b20dd.tar.bz2
mitmproxy-4495562f86de5c3f41a0cf1616c08e74f45b20dd.zip
unvendor wsproto
Diffstat (limited to 'mitmproxy/websocket.py')
-rw-r--r--mitmproxy/websocket.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/mitmproxy/websocket.py b/mitmproxy/websocket.py
index a37edb54..66257852 100644
--- a/mitmproxy/websocket.py
+++ b/mitmproxy/websocket.py
@@ -1,7 +1,8 @@
import time
from typing import List, Optional
-from mitmproxy.contrib import wsproto
+from wsproto.frame_protocol import CloseReason
+from wsproto.frame_protocol import Opcode
from mitmproxy import flow
from mitmproxy.net import websockets
@@ -17,7 +18,7 @@ class WebSocketMessage(serializable.Serializable):
def __init__(
self, type: int, from_client: bool, content: bytes, timestamp: Optional[int]=None, killed: bool=False
) -> None:
- self.type = wsproto.frame_protocol.Opcode(type) # type: ignore
+ self.type = Opcode(type) # type: ignore
"""indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode)."""
self.from_client = from_client
"""True if this messages was sent by the client."""
@@ -37,10 +38,10 @@ class WebSocketMessage(serializable.Serializable):
def set_state(self, state):
self.type, self.from_client, self.content, self.timestamp, self.killed = state
- self.type = wsproto.frame_protocol.Opcode(self.type) # replace enum with bare int
+ self.type = Opcode(self.type) # replace enum with bare int
def __repr__(self):
- if self.type == wsproto.frame_protocol.Opcode.TEXT:
+ if self.type == Opcode.TEXT:
return "text message: {}".format(repr(self.content))
else:
return "binary message: {}".format(strutils.bytes_to_escaped_str(self.content))
@@ -66,7 +67,7 @@ class WebSocketFlow(flow.Flow):
"""A list containing all WebSocketMessage's."""
self.close_sender = 'client'
"""'client' if the client initiated connection closing."""
- self.close_code = wsproto.frame_protocol.CloseReason.NORMAL_CLOSURE
+ self.close_code = CloseReason.NORMAL_CLOSURE
"""WebSocket close code."""
self.close_message = '(message missing)'
"""WebSocket close message."""