aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-03-13 16:21:41 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-03-13 16:21:41 +1300
commit49c1532af76594338ffbd12e4daaed9501471f6f (patch)
tree12d1a850dc255a6c6eb63f4e8534a7b40e26e0e8
parentef27e2fb29f9c05ee8ed619f0444156fd823b283 (diff)
downloadmitmproxy-49c1532af76594338ffbd12e4daaed9501471f6f.tar.gz
mitmproxy-49c1532af76594338ffbd12e4daaed9501471f6f.tar.bz2
mitmproxy-49c1532af76594338ffbd12e4daaed9501471f6f.zip
Add anticache support for mitmproxy
Also stub out an option toggle command for anticache, killextra and norefresh options.
-rw-r--r--libmproxy/console.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py
index d9a70e74..f13bc933 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -27,10 +27,18 @@ class Stop(Exception): pass
def format_keyvals(lst, key="key", val="text", space=5, indent=0):
ret = []
if lst:
- pad = max(len(i[0]) for i in lst if i) + space
+ pad = max(len(i[0]) for i in lst if i and i[0]) + space
for i in lst:
if i is None:
ret.extend("\n")
+ elif i[0] is None:
+ ret.extend(
+ [
+ " "*(pad + indent),
+ (val, i[1]),
+ "\n"
+ ]
+ )
else:
ret.extend(
[
@@ -679,7 +687,8 @@ class StatusBar(WWrap):
r.append("[")
r.append(("statusbar_highlight", "t"))
r.append(":%s]"%self.master.stickycookie_txt)
-
+ if self.master.anticache:
+ r.append("[anticache]")
return r
@@ -861,6 +870,7 @@ class ConsoleMaster(flow.FlowMaster):
self.stickycookie = None
self.stickyhosts = {}
+ self.anticache = options.anticache
def spawn_external_viewer(self, data, contenttype):
@@ -1054,6 +1064,10 @@ class ConsoleMaster(flow.FlowMaster):
("j, k", "up, down"),
("l", "set limit filter pattern"),
("L", "load saved flows"),
+ ("o", "toggle options:"),
+ (None, " anticache: modify requests to prevent cached responses"),
+ (None, " killextra: kill requests not part of server replay"),
+ (None, " norefresh: disable server replay response refresh"),
("q", "quit / return to connection list"),
("Q", "quit without confirm prompt"),
("r", "replay request"),
@@ -1282,6 +1296,17 @@ class ConsoleMaster(flow.FlowMaster):
self.load_flows
)
k = None
+ elif k == "o":
+ self.prompt_onekey(
+ "Options",
+ (
+ ("anticache", "a"),
+ ("killextra", "k"),
+ ("norefresh", "n"),
+ ),
+ self._change_options
+ )
+ k = None
elif k == "t":
self.prompt(
"Sticky cookie: ",
@@ -1298,6 +1323,10 @@ class ConsoleMaster(flow.FlowMaster):
if a != "n":
raise Stop
+ def _change_options(self, a):
+ if a == "a":
+ self.anticache = not self.anticache
+
def shutdown(self):
for i in self.state.flow_list:
i.kill()