aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console.py
diff options
context:
space:
mode:
authorStephen Altamirano <stephen@evilrobotstuff.com>2011-07-21 22:09:48 -0700
committerStephen Altamirano <stephen@evilrobotstuff.com>2011-07-21 22:09:48 -0700
commit9c24401b187fa2915d8b6cc424fc25f5e51369c8 (patch)
treed3b0bd6baafa906f418fe3c6b37f9cbe5ecb6474 /libmproxy/console.py
parent74d8b18408783172ecdba5ec3947a4ecb590d70d (diff)
downloadmitmproxy-9c24401b187fa2915d8b6cc424fc25f5e51369c8.tar.gz
mitmproxy-9c24401b187fa2915d8b6cc424fc25f5e51369c8.tar.bz2
mitmproxy-9c24401b187fa2915d8b6cc424fc25f5e51369c8.zip
Removes last_encoding attribute from Response. Prompts for encoding on identity responses
Diffstat (limited to 'libmproxy/console.py')
-rw-r--r--libmproxy/console.py38
1 files changed, 27 insertions, 11 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py
index 3017669e..3e5ece1d 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -533,23 +533,39 @@ class ConnectionView(WWrap):
elif key == "z":
if self.state.view_flow_mode == VIEW_FLOW_RESPONSE:
conn = self.flow.response
- e = conn.headers["content-encoding"]
- if e:
- if conn.last_encoding:
- conn.content = encoding.encode(
- conn.last_encoding,
- encoding.decode(e[0], conn.content)
- )
- conn.last_encoding, conn.headers["content-encoding"] = e[0], [conn.last_encoding]
- else:
- conn.last_encoding = "identity"
- self.master.refresh_connection(self.flow)
+ e = conn.headers["content-encoding"] or ["identity"]
+ if e[0] != "identity":
+ conn.content = encoding.decode(e[0], conn.content)
+ conn.headers["content-encoding"] = ["identity"]
+ else:
+ self.master.prompt_onekey(
+ "Select encoding: ",
+ (
+ ("gzip", "z"),
+ ("deflate", "d"),
+ ),
+ self.encode_response_callback
+ )
+ self.master.refresh_connection(self.flow)
return key
def run_script(self, path):
if path:
self.master._runscript(self.flow, path)
+ def encode_response_callback(self, key):
+ conn = self.flow.response
+ encoding_map = {
+ "z": "gzip",
+ "d": "deflate",
+ }
+ conn.content = encoding.encode(
+ encoding_map[key],
+ conn.content
+ )
+ conn.headers["content-encoding"] = [encoding_map[key]]
+ self.master.refresh_connection(self.flow)
+
class _PathCompleter:
def __init__(self, _testing=False):