diff options
author | Maximilian Hils <git@maximilianhils.com> | 2020-04-08 20:21:12 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2020-04-08 20:21:12 +0200 |
commit | 9d5305301a8e073cbb64bb6574e66bb34373935a (patch) | |
tree | 7f30b0412a9974751846c757d44889694d00dc7b /examples/addons/events-websocket-specific.py | |
parent | 40925181e9d64c727f75e89acf0205bb4b87bb3a (diff) | |
parent | 4d6886a0f4ebbf6bc66b74fa548ff724ba2ad660 (diff) | |
download | mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.tar.gz mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.tar.bz2 mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.zip |
Merge remote-tracking branch 'origin/master' into fix-ci
Diffstat (limited to 'examples/addons/events-websocket-specific.py')
-rw-r--r-- | examples/addons/events-websocket-specific.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/addons/events-websocket-specific.py b/examples/addons/events-websocket-specific.py new file mode 100644 index 00000000..60069fdb --- /dev/null +++ b/examples/addons/events-websocket-specific.py @@ -0,0 +1,36 @@ +import mitmproxy.http +import mitmproxy.websocket + + +class Events: + # Websocket lifecycle + def websocket_handshake(self, flow: mitmproxy.http.HTTPFlow): + """ + Called when a client wants to establish a WebSocket connection. The + WebSocket-specific headers can be manipulated to alter the + handshake. The flow object is guaranteed to have a non-None request + attribute. + """ + + def websocket_start(self, flow: mitmproxy.websocket.WebSocketFlow): + """ + A websocket connection has commenced. + """ + + def websocket_message(self, flow: mitmproxy.websocket.WebSocketFlow): + """ + Called when a WebSocket message is received from the client or + server. The most recent message will be flow.messages[-1]. The + message is user-modifiable. Currently there are two types of + messages, corresponding to the BINARY and TEXT frame types. + """ + + def websocket_error(self, flow: mitmproxy.websocket.WebSocketFlow): + """ + A websocket connection has had an error. + """ + + def websocket_end(self, flow: mitmproxy.websocket.WebSocketFlow): + """ + A websocket connection has ended. + """ |