diff --git a/mitmproxy/README.md b/mitmproxy/README.md index 7fbbf4d..abffb20 100644 --- a/mitmproxy/README.md +++ b/mitmproxy/README.md @@ -1,3 +1,21 @@ +# `dump.py` +```python +I = lambda module: __import__('importlib').import_module(module) + +def request(flow): + with I('dbm.sqlite3').open('dbm.sql') as db: + if (url := flow.request.url) in db: + flow.response = I('mitmproxy.http').Response.make(200, db[url]) + +def response(flow): + if flow.response.status_code == 200: + with I('dbm.sqlite3').open('dbm.sql', 'c') as db: + db[flow.request.url] = flow.response.content + +if __name__ == '__main__': + I('subprocess').run(['mitmdump', '-s', __file__]) +``` + # Retries if failed ```python def response(flow):