~ubuntu-branches/ubuntu/quantal/mitmproxy/quantal

« back to all changes in this revision

Viewing changes to examples/stub.py

  • Committer: Package Import Robot
  • Author(s): Sebastien Delafond
  • Date: 2012-02-13 11:46:52 UTC
  • Revision ID: package-import@ubuntu.com-20120213114652-ug49uqn1be6w80h9
Tags: upstream-0.6
ImportĀ upstreamĀ versionĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
    This is a script stub, with definitions for all events.
 
3
"""
 
4
 
 
5
def start(ctx):
 
6
    """
 
7
        Called once on script startup, before any other events.
 
8
    """
 
9
    ctx.log("start")
 
10
 
 
11
def clientconnect(ctx, client_connect):
 
12
    """
 
13
        Called when a client initiates a connection to the proxy. Note that a
 
14
        connection can correspond to multiple HTTP requests
 
15
    """
 
16
    ctx.log("clientconnect")
 
17
 
 
18
def request(ctx, flow):
 
19
    """
 
20
        Called when a client request has been received.
 
21
    """
 
22
    ctx.log("request")
 
23
 
 
24
def response(ctx, flow):
 
25
    """
 
26
       Called when a server response has been received.
 
27
    """
 
28
    ctx.log("response")
 
29
 
 
30
def error(ctx, flow):
 
31
    """
 
32
        Called when a flow error has occured, e.g. invalid server responses, or
 
33
        interrupted connections. This is distinct from a valid server HTTP error
 
34
        response, which is simply a response with an HTTP error code. 
 
35
    """
 
36
    ctx.log("error")
 
37
 
 
38
def clientdisconnect(ctx, client_disconnect):
 
39
    """
 
40
        Called when a client disconnects from the proxy.
 
41
    """
 
42
    ctx.log("clientdisconnect")
 
43
 
 
44
def done(ctx):
 
45
    """
 
46
        Called once on script shutdown, after any other events.
 
47
    """
 
48
    ctx.log("done")