aboutsummaryrefslogtreecommitdiffstats
path: root/docs/scripting/overview.rst
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-11-21 02:16:20 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-11-21 02:28:10 +0100
commit9af8f4bb31c94a25780a4189bffa406906249626 (patch)
treecf52f1c312b7bac3d83d796d6b03bb33b4556f26 /docs/scripting/overview.rst
parentf74e561524d04c93cd7953f34e78ebe67eaa58a8 (diff)
downloadmitmproxy-9af8f4bb31c94a25780a4189bffa406906249626.tar.gz
mitmproxy-9af8f4bb31c94a25780a4189bffa406906249626.tar.bz2
mitmproxy-9af8f4bb31c94a25780a4189bffa406906249626.zip
organize examples
This commit is largely based on work by Thiago Arrais (@thiagoarrais) and Shane Bradfield (@l33tLumberjack). I wasn't really able to get their PR reasonably merged onto the latest master, so I reapplied their changes manually here and did some further improvements on that.
Diffstat (limited to 'docs/scripting/overview.rst')
-rw-r--r--docs/scripting/overview.rst22
1 files changed, 11 insertions, 11 deletions
diff --git a/docs/scripting/overview.rst b/docs/scripting/overview.rst
index 7e399c9c..7df5532d 100644
--- a/docs/scripting/overview.rst
+++ b/docs/scripting/overview.rst
@@ -17,8 +17,8 @@ appropriate points of mitmproxy's operation. Here's a complete mitmproxy script
that adds a new header to every HTTP response before it is returned to the
client:
-.. literalinclude:: ../../examples/add_header.py
- :caption: :src:`examples/add_header.py`
+.. literalinclude:: ../../examples/simple/add_header.py
+ :caption: :src:`examples/simple/add_header.py`
:language: python
All events that deal with an HTTP request get an instance of `HTTPFlow
@@ -42,8 +42,8 @@ called before anything else happens. You can replace the current script object
by returning it from this handler. Here's how this looks when applied to the
example above:
-.. literalinclude:: ../../examples/classes.py
- :caption: :src:`examples/classes.py`
+.. literalinclude:: ../../examples/simple/add_header_class.py
+ :caption: :src:`examples/simple/add_header_class.py`
:language: python
So here, we're using a module-level script to "boot up" into a class instance.
@@ -62,13 +62,13 @@ sophisticated - replace one value with another in all responses. Mitmproxy's
<api.html#mitmproxy.models.http.HTTPResponse.replace>`_ method that takes care
of all the details for us.
-.. literalinclude:: ../../examples/arguments.py
- :caption: :src:`examples/arguments.py`
+.. literalinclude:: ../../examples/simple/script_arguments.py
+ :caption: :src:`examples/simple/script_arguments.py`
:language: python
We can now call this script on the command-line like this:
->>> mitmdump -dd -s "./arguments.py html faketml"
+>>> mitmdump -dd -s "./script_arguments.py html faketml"
Whenever a handler is called, mitpmroxy rewrites the script environment so that
it sees its own arguments as if it was invoked from the command-line.
@@ -85,8 +85,8 @@ and mitmproxy console can place script output in the event buffer.
Here's how this looks:
-.. literalinclude:: ../../examples/context_logging.py
- :caption: :src:`examples/context_logging.py`
+.. literalinclude:: ../../examples/simple/logging.py
+ :caption: :src:`examples/simple/logging.py`
:language: python
The ``ctx`` module also exposes the mitmproxy master object at ``ctx.master``
@@ -126,8 +126,8 @@ It's possible to implement a concurrent mechanism on top of the blocking
framework, and mitmproxy includes a handy example of this that is fit for most
purposes. You can use it as follows:
-.. literalinclude:: ../../examples/nonblocking.py
- :caption: :src:`examples/nonblocking.py`
+.. literalinclude:: ../../examples/complex/nonblocking.py
+ :caption: :src:`examples/complex/nonblocking.py`
:language: python