I finally upgraded my Python version from 2.7 to 3.6.1 and with that also upgraded my mitmproxy
from the old and good v0.16 to the newest version.
I used to work with libmproxy
in order to manipulate the requests that were diverted through the proxy with this syntax:
from netlib.http import decoded
from libmproxy import controller, proxy
from libmproxy.proxy.server import ProxyServer
class StickyMaster(controller.Master):
def __init__(self, server):
controller.Master.__init__(self, server)
self.stickyhosts = {}
def run(self):
try:
return controller.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, flow):
flow.reply()
def handle_response(self, flow):
with decoded(flow.response):
<DO SOMETHING>
flow.reply()
config = proxy.ProxyConfig(port=8081)
server = ProxyServer(config)
m = StickyMaster(server)
m.run()
I understood that in the new version the syntax is totally different and I can't find a relevant documentation with an example of how to do that right.
Can anybody share with me an example of a basic code such as I wrote above of the newest version?