I was trying to use mitmproxy
(version 0.8.1 installed with pip
on Mac OS 10.7.4) in server-replay mode to fake a response, which I thought would be easier than hacking the server for the test I was running. Turns out it wasn't.
I edited the response body and saved the flow with no problem, except that in doing so I changed the length of the response. Unfortunately mitmproxy
did not change the Content-Length:
header to match, so I had to edit that, too. Then when I tried to save the flow I got this error:
Traceback (most recent call last):
File "/usr/local/bin/mitmproxy", line 64, in
m.run()
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 538, in run
self.ui.run_wrapper(self.loop)
File "/Library/Python/2.7/site-packages/urwid/raw_display.py", line 237, in run_wrapper
return fn()
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 762, in loop
self.prompt_execute()
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 689, in prompt_execute
msg = p(txt, *args)
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 619, in save_one_flow
return self._write_flows(path, [flow])
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 613, in _write_flows
fw.add(i)
File "/Library/Python/2.7/site-packages/libmproxy/flow.py", line 1557, in add
tnetstring.dump(d, self.fo)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 103, in dump
file.write(dumps(value,encoding))
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 93, in dumps
_rdumpq(q,0,value,encoding)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 174, in _rdumpq
size = _rdumpq(q,size,v,encoding)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 174, in _rdumpq
size = _rdumpq(q,size,v,encoding)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 165, in _rdumpq
size = _rdumpq(q,size,item,encoding)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 165, in _rdumpq
size = _rdumpq(q,size,item,encoding)
File "/Library/Python/2.7/site-packages/libmproxy/tnetstring.py", line 182, in _rdumpq
raise ValueError("must specify encoding to dump unicode strings")
ValueError: must specify encoding to dump unicode strings
At which point there was no console display but mitmproxy
was still running. The only way I found to kill it was to switch to another terminal window and kill the process.
I was unsuccessful at trying to edit the saved flow with vi
or emacs
, either: after editing, mitmproxy
would not load them. When I tried to load them via the UI, the UI showed "Invalid data format." When I tried to load the flow with mitmproxy -S flowfile
it crashed:
Traceback (most recent call last):
File "/usr/local/bin/mitmproxy", line 63, in
m = console.ConsoleMaster(server, opts)
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 392, in init
self.server_playback_path(options.server_replay)
File "/Library/Python/2.7/site-packages/libmproxy/console/init.py", line 451, in server_playback_path
self.statusbar.message(ret)
AttributeError: ConsoleMaster instance has no attribute 'statusbar'