Merge pull request #3186 from andersonvom/master

Add scripting example to intercept & change requests
This commit is contained in:
Aldo Cortesi 2018-07-11 10:24:52 +12:00 committed by GitHub
commit 9829fe150e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -14,4 +14,19 @@ handler functions in the module scope. For instance, here is a complete script
that adds a header to every request.
{{< example src="examples/addons/scripting.py" lang="py" >}}
{{< example src="examples/addons/scripting-headers.py" lang="py" >}}
Here's another example that intercepts requests to a particular URL and sends
an arbitrary response instead:
{{< example src="examples/simple/send_reply_from_proxy.py" lang="py" >}}
You can look at the [http][] module, or the [Request][], and
[Response][] classes for other attributes that you can use when
scripting.
[http][]: https://github.com/mitmproxy/mitmproxy/blob/master/mitmproxy/http.py
[Request]: https://github.com/mitmproxy/mitmproxy/blob/master/mitmproxy/net/http/request.py
[Response]: https://github.com/mitmproxy/mitmproxy/blob/master/mitmproxy/net/http/response.py