aboutsummaryrefslogtreecommitdiffstats
path: root/doc-src/scripts.html
blob: 990ca0705ffb6ed789e6deabb8d8f800c7ff4cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__mitmproxy__ has a powerful event-drive scripting API, that allows you to
modify flows on-the-fly or rewrite previously saved flows locally. 


## Events

<table>
    <tr>
        <td>start(ctx)</td>
        <td>Called once on startup, before any other events.</td>
    </tr>
    <tr>
        <td>clientconnect(ctx, ClientConnect)</td>
        <td>Called when a client initiates a connection to the proxy. Note that
        a connection can correspond to multiple HTTP requests.</td>
    </tr>
    <tr>
        <td>request(ctx, Flow)</td>
        <td>Called when a client request has been received.</td>
    </tr>
    <tr>
        <td>response(ctx, Flow)</td>
        <td>Called when a server response has been received.</td>
    </tr>
    <tr>
        <td>error(ctx, Flow)</td>
        <td>Called when a flow error has occured, e.g. invalid server
        responses, or interrupted connections. This is distinct from a valid
        server HTTP error response, which is simply a response with an HTTP
        error code. </td>
    </tr>
    <tr>
        <td>clientdisconnect(ctx, ClientDisconnect)</td>
        <td>Called when a client disconnects from the proxy.</td>
    </tr>
    <tr>
        <td>done(ctx)</td>
        <td>Called once on script shutdown, after any other events.</td>
    </tr>
</table>