diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-11-23 22:45:21 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-11-23 22:45:21 +0100 |
commit | 5d209e504004f8eb7f28c1b835266415528bbd27 (patch) | |
tree | fb7e64ac3290f286e0f4677a71b62ebb612b75e6 /docs/scripting | |
parent | 48d54e2d4a1a61a635f74c33f0544be8172a10fc (diff) | |
parent | 9bc5adfb03ca6fc08a115757e3de18299a06b091 (diff) | |
download | mitmproxy-5d209e504004f8eb7f28c1b835266415528bbd27.tar.gz mitmproxy-5d209e504004f8eb7f28c1b835266415528bbd27.tar.bz2 mitmproxy-5d209e504004f8eb7f28c1b835266415528bbd27.zip |
Merge commit '9bc5adf'
Diffstat (limited to 'docs/scripting')
-rw-r--r-- | docs/scripting/events.rst | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/docs/scripting/events.rst b/docs/scripting/events.rst index 5f560e58..8f9463ff 100644 --- a/docs/scripting/events.rst +++ b/docs/scripting/events.rst @@ -158,21 +158,54 @@ HTTP Events WebSocket Events ----------------- +These events are called only after a connection made an HTTP upgrade with +"101 Switching Protocols". No further HTTP-related events after the handshake +are issued, only new WebSocket messages are called. + .. list-table:: :widths: 40 60 :header-rows: 0 - * - .. py:function:: websockets_handshake(flow) - - - Called when a client wants to establish a WebSockets connection. The - WebSockets-specific headers can be manipulated to manipulate the + * - .. py:function:: websocket_handshake(flow) + - 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. *flow* - The flow containing the HTTP websocket handshake request. The + The flow containing the HTTP WebSocket handshake request. The object is guaranteed to have a non-None ``request`` attribute. + * - .. py:function:: websocket_start(flow) + - Called when WebSocket connection is established after a successful + handshake. + + *flow* + A ``models.WebSocketFlow`` object. + + * - .. py:function:: websocket_message(flow) + + - Called when a WebSocket message is received from the client or server. The + sender and receiver are identifiable. 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. + + *flow* + A ``models.WebSocketFlow`` object. + + * - .. py:function:: websocket_end(flow) + - Called when WebSocket connection ends. + + *flow* + A ``models.WebSocketFlow`` object. + + * - .. py:function:: websocket_error(flow) + - Called when a WebSocket error occurs - e.g. the connection closing + unexpectedly. + + *flow* + A ``models.WebSocketFlow`` object. + TCP Events ---------- @@ -185,30 +218,31 @@ connections. :widths: 40 60 :header-rows: 0 - * - .. py:function:: tcp_end(flow) - - Called when TCP streaming ends. - - *flow* - A ``models.TCPFlow`` object. - * - .. py:function:: tcp_error(flow) - - Called when a TCP error occurs - e.g. the connection closing - unexpectedly. + * - .. py:function:: tcp_start(flow) + - Called when TCP streaming starts. *flow* A ``models.TCPFlow`` object. * - .. py:function:: tcp_message(flow) - - Called a TCP payload is received from the client or server. The + - Called when a TCP payload is received from the client or server. The sender and receiver are identifiable. The most recent message will be ``flow.messages[-1]``. The message is user-modifiable. *flow* A ``models.TCPFlow`` object. - * - .. py:function:: tcp_start(flow) - - Called when TCP streaming starts. + * - .. py:function:: tcp_end(flow) + - Called when TCP streaming ends. + + *flow* + A ``models.TCPFlow`` object. + + * - .. py:function:: tcp_error(flow) + - Called when a TCP error occurs - e.g. the connection closing + unexpectedly. *flow* A ``models.TCPFlow`` object. |