Both mitmproxy and mitmdump allow you to modify requests and responses with external scripts. This is often done through the --reqscript and --respscript options
The script interface is simple - scripts simply read, modify and return a single libmproxy.flow.Flow object, using the methods defined in the libmproxy.script module. Scripts must be executable.
#!/usr/bin/env python
from libmproxy import script
f = script.load_flow()
f.request.headers["newheader"] = ["foo"]
script.return_flow(f)
© mitmproxy project, 2011