mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
add example to shutdown the proxy master
This commit is contained in:
parent
9c3596219d
commit
04cda70d1a
1 changed files with 18 additions and 0 deletions
18
examples/addons/shutdown.py
Normal file
18
examples/addons/shutdown.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"""
|
||||
A simple way of shutting down the mitmproxy instance to stop everything.
|
||||
|
||||
Usage:
|
||||
|
||||
mitmproxy -s shutdown.py
|
||||
|
||||
and then send a HTTP request to trigger the shutdown:
|
||||
curl --proxy localhost:8080 http://example.com/path
|
||||
"""
|
||||
from mitmproxy import ctx, http
|
||||
|
||||
|
||||
def request(flow: http.HTTPFlow) -> None:
|
||||
# a random condition to make this example a bit more interactive
|
||||
if flow.request.pretty_url == "http://example.com/path":
|
||||
ctx.log.info("Shutting down everything...")
|
||||
ctx.master.shutdown()
|
||||
Loading…
Add table
Add a link
Reference in a new issue