mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
08895e9ba6
- restructure examples (fix #4031) - remove example dependencies from setup.py, we do not need special dependencies for our supported addons. - unify how we generate docs from code - improve example docs
32 lines
592 B
Python
32 lines
592 B
Python
"""
|
|
Add a new mitmproxy option.
|
|
|
|
Usage:
|
|
|
|
mitmproxy -s options-simple.py --set addheader true
|
|
"""
|
|
from mitmproxy import ctx
|
|
|
|
|
|
class AddHeader:
|
|
def __init__(self):
|
|
self.num = 0
|
|
|
|
def load(self, loader):
|
|
loader.add_option(
|
|
name = "addheader",
|
|
typespec = bool,
|
|
default = False,
|
|
help = "Add a count header to responses",
|
|
)
|
|
|
|
def response(self, flow):
|
|
if ctx.options.addheader:
|
|
self.num = self.num + 1
|
|
flow.response.headers["count"] = str(self.num)
|
|
|
|
|
|
addons = [
|
|
AddHeader()
|
|
]
|