diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-08-05 10:47:43 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-08-05 10:47:43 +1200 |
commit | 89a58d7e303f00e4ed7572b60db6a2073804c4a1 (patch) | |
tree | 643ed3d3ef9fbdf3ddc65ba80ef8cc173cb52a94 /examples | |
parent | 98a7aaca182ce6b879329bbaeb06efca284c6220 (diff) | |
download | mitmproxy-89a58d7e303f00e4ed7572b60db6a2073804c4a1.tar.gz mitmproxy-89a58d7e303f00e4ed7572b60db6a2073804c4a1.tar.bz2 mitmproxy-89a58d7e303f00e4ed7572b60db6a2073804c4a1.zip |
Start on scripting documentation and examples.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/add_header.py | 2 | ||||
-rw-r--r-- | examples/stub.py | 47 |
2 files changed, 47 insertions, 2 deletions
diff --git a/examples/add_header.py b/examples/add_header.py index dab33c8c..6ddeab3d 100644 --- a/examples/add_header.py +++ b/examples/add_header.py @@ -1,8 +1,6 @@ -#!/usr/bin/env python """ This script adds a new header to all responses. """ -from libmproxy import script def response(ctx, f): f.response.headers["newheader"] = ["foo"] diff --git a/examples/stub.py b/examples/stub.py new file mode 100644 index 00000000..f235ea85 --- /dev/null +++ b/examples/stub.py @@ -0,0 +1,47 @@ +""" + This is a script stub, with empty definitions for all events. +""" + +def start(ctx): + """ + Called once on script startup, before any other events. + """ + pass + +def clientconnect(ctx, client_connect): + """ + Called when a client initiates a connection to the proxy. Note that a + connection can correspond to multiple HTTP requests + """ + pass + +def request(ctx, flow): + """ + Called when a client request has been received. + """ + +def response(ctx, flow): + """ + Called when a server response has been received. + """ + pass + +def error(ctx, flow): + """ + 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. + """ + pass + +def clientdisconnect(ctx, client_disconnect): + """ + Called when a client disconnects from the proxy. + """ + pass + +def done(ctx): + """ + Called once on script shutdown, after any other events. + """ + pass |