mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Rip out autodecode
We simplify things as follows: - If we're in "pretty" view mode, we autodecode. - Otherwise, we display raw data, and the user can manually encode/decode with z shortcut.
This commit is contained in:
parent
b51aac8a86
commit
87623a8d75
@ -17,7 +17,6 @@ def get_common_options(options):
|
|||||||
return dict(
|
return dict(
|
||||||
anticache = options.anticache,
|
anticache = options.anticache,
|
||||||
anticomp = options.anticomp,
|
anticomp = options.anticomp,
|
||||||
autodecode = options.autodecode,
|
|
||||||
client_replay = options.client_replay,
|
client_replay = options.client_replay,
|
||||||
eventlog = options.eventlog,
|
eventlog = options.eventlog,
|
||||||
kill = options.kill,
|
kill = options.kill,
|
||||||
@ -50,11 +49,6 @@ def common_options(parser):
|
|||||||
action="store", type = "str", dest="confdir", default='~/.mitmproxy',
|
action="store", type = "str", dest="confdir", default='~/.mitmproxy',
|
||||||
help = "Configuration directory. (~/.mitmproxy)"
|
help = "Configuration directory. (~/.mitmproxy)"
|
||||||
)
|
)
|
||||||
parser.add_option(
|
|
||||||
"-d",
|
|
||||||
action="store_true", dest="autodecode",
|
|
||||||
help="Automatically decode compressed server responses."
|
|
||||||
)
|
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-e",
|
"-e",
|
||||||
action="store_true", dest="eventlog",
|
action="store_true", dest="eventlog",
|
||||||
|
@ -343,10 +343,7 @@ class ConnectionView(WWrap):
|
|||||||
def _conn_text(self, conn, viewmode):
|
def _conn_text(self, conn, viewmode):
|
||||||
if conn:
|
if conn:
|
||||||
e = conn.headers["content-encoding"]
|
e = conn.headers["content-encoding"]
|
||||||
if e and self.master.autodecode:
|
e = e[0] if e else None
|
||||||
e = e[0]
|
|
||||||
else:
|
|
||||||
e = "identity"
|
|
||||||
return self.master._cached_conn_text(
|
return self.master._cached_conn_text(
|
||||||
e,
|
e,
|
||||||
conn.content,
|
conn.content,
|
||||||
@ -716,8 +713,6 @@ class StatusBar(WWrap):
|
|||||||
opts.append("anticache")
|
opts.append("anticache")
|
||||||
if self.master.anticomp:
|
if self.master.anticomp:
|
||||||
opts.append("anticomp")
|
opts.append("anticomp")
|
||||||
if self.master.autodecode:
|
|
||||||
opts.append("autodecode")
|
|
||||||
if not self.master.refresh_server_playback:
|
if not self.master.refresh_server_playback:
|
||||||
opts.append("norefresh")
|
opts.append("norefresh")
|
||||||
if self.master.killextra:
|
if self.master.killextra:
|
||||||
@ -854,7 +849,6 @@ class Options(object):
|
|||||||
__slots__ = [
|
__slots__ = [
|
||||||
"anticache",
|
"anticache",
|
||||||
"anticomp",
|
"anticomp",
|
||||||
"autodecode",
|
|
||||||
"client_replay",
|
"client_replay",
|
||||||
"debug",
|
"debug",
|
||||||
"eventlog",
|
"eventlog",
|
||||||
@ -979,7 +973,6 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.refresh_server_playback = options.refresh_server_playback
|
self.refresh_server_playback = options.refresh_server_playback
|
||||||
self.anticache = options.anticache
|
self.anticache = options.anticache
|
||||||
self.anticomp = options.anticomp
|
self.anticomp = options.anticomp
|
||||||
self.autodecode = options.autodecode
|
|
||||||
self.killextra = options.kill
|
self.killextra = options.kill
|
||||||
self.rheaders = options.rheaders
|
self.rheaders = options.rheaders
|
||||||
|
|
||||||
@ -1107,12 +1100,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
return self._view_conn_raw(content)
|
return self._view_conn_raw(content)
|
||||||
|
|
||||||
@utils.LRUCache(20)
|
@utils.LRUCache(20)
|
||||||
def _cached_conn_text(self, e, rawcontent, hdrItems, viewmode):
|
def _cached_conn_text(self, e, content, hdrItems, viewmode):
|
||||||
content = encoding.decode(e, rawcontent)
|
|
||||||
if content is None:
|
|
||||||
content = rawcontent
|
|
||||||
e = None
|
|
||||||
|
|
||||||
hdr = []
|
hdr = []
|
||||||
hdr.extend(
|
hdr.extend(
|
||||||
format_keyvals(
|
format_keyvals(
|
||||||
@ -1124,14 +1112,18 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
hdr.append("\n")
|
hdr.append("\n")
|
||||||
|
|
||||||
txt = [urwid.Text(hdr)]
|
txt = [urwid.Text(hdr)]
|
||||||
if e and e != "identity":
|
|
||||||
txt.append(
|
|
||||||
urwid.Text(("highlight", "Decoded %s data:\n"%e))
|
|
||||||
)
|
|
||||||
if content:
|
if content:
|
||||||
if viewmode == VIEW_BODY_HEX:
|
if viewmode == VIEW_BODY_HEX:
|
||||||
txt.extend(self._view_conn_binary(content))
|
txt.extend(self._view_conn_binary(content))
|
||||||
elif viewmode == VIEW_BODY_PRETTY:
|
elif viewmode == VIEW_BODY_PRETTY:
|
||||||
|
if e:
|
||||||
|
decoded = encoding.decode(e, content)
|
||||||
|
if decoded:
|
||||||
|
content = decoded
|
||||||
|
if e and e != "identity":
|
||||||
|
txt.append(
|
||||||
|
urwid.Text(("highlight", "Decoded %s data:\n"%e))
|
||||||
|
)
|
||||||
txt.extend(self._find_pretty_view(content, hdrItems))
|
txt.extend(self._find_pretty_view(content, hdrItems))
|
||||||
else:
|
else:
|
||||||
txt.extend(self._view_conn_raw(content))
|
txt.extend(self._view_conn_raw(content))
|
||||||
@ -1398,10 +1390,6 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
highlight_key("anticomp", "c") +
|
highlight_key("anticomp", "c") +
|
||||||
[("text", ": prevent compressed responses")]
|
[("text", ": prevent compressed responses")]
|
||||||
),
|
),
|
||||||
(None,
|
|
||||||
highlight_key("autodecode", "d") +
|
|
||||||
[("text", ": auto-decode compressed content")]
|
|
||||||
),
|
|
||||||
(None,
|
(None,
|
||||||
highlight_key("killextra", "k") +
|
highlight_key("killextra", "k") +
|
||||||
[("text", ": kill requests not part of server replay")]
|
[("text", ": kill requests not part of server replay")]
|
||||||
@ -1710,7 +1698,6 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
(
|
(
|
||||||
("anticache", "a"),
|
("anticache", "a"),
|
||||||
("anticomp", "c"),
|
("anticomp", "c"),
|
||||||
("autodecode", "d"),
|
|
||||||
("killextra", "k"),
|
("killextra", "k"),
|
||||||
("norefresh", "n"),
|
("norefresh", "n"),
|
||||||
),
|
),
|
||||||
@ -1754,9 +1741,6 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.anticache = not self.anticache
|
self.anticache = not self.anticache
|
||||||
if a == "c":
|
if a == "c":
|
||||||
self.anticomp = not self.anticomp
|
self.anticomp = not self.anticomp
|
||||||
elif a == "d":
|
|
||||||
self.autodecode = not self.autodecode
|
|
||||||
self.refresh_connection(self.currentflow)
|
|
||||||
elif a == "k":
|
elif a == "k":
|
||||||
self.killextra = not self.killextra
|
self.killextra = not self.killextra
|
||||||
elif a == "n":
|
elif a == "n":
|
||||||
|
@ -8,7 +8,6 @@ class Options(object):
|
|||||||
__slots__ = [
|
__slots__ = [
|
||||||
"anticache",
|
"anticache",
|
||||||
"anticomp",
|
"anticomp",
|
||||||
"autodecode",
|
|
||||||
"client_replay",
|
"client_replay",
|
||||||
"eventlog",
|
"eventlog",
|
||||||
"keepserving",
|
"keepserving",
|
||||||
@ -57,7 +56,6 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
self.o = options
|
self.o = options
|
||||||
self.anticache = options.anticache
|
self.anticache = options.anticache
|
||||||
self.anticomp = options.anticomp
|
self.anticomp = options.anticomp
|
||||||
self.autodecode = options.autodecode
|
|
||||||
self.eventlog = options.eventlog
|
self.eventlog = options.eventlog
|
||||||
self.refresh_server_playback = options.refresh_server_playback
|
self.refresh_server_playback = options.refresh_server_playback
|
||||||
|
|
||||||
|
@ -1087,7 +1087,6 @@ class FlowMaster(controller.Master):
|
|||||||
|
|
||||||
self.anticache = False
|
self.anticache = False
|
||||||
self.anticomp = False
|
self.anticomp = False
|
||||||
self.autodecode = False
|
|
||||||
self.refresh_server_playback = False
|
self.refresh_server_playback = False
|
||||||
|
|
||||||
def add_event(self, e, level="info"):
|
def add_event(self, e, level="info"):
|
||||||
|
Loading…
Reference in New Issue
Block a user