aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-07-28 11:19:07 +1200
committerAldo Cortesi <aldo@nullcube.com>2011-07-28 11:19:07 +1200
commitc89c4361c376765c666cc6ed0ab5834b2418082d (patch)
treead5c9e10f6797c92f281e71f5fc49af427253528 /libmproxy/proxy.py
parent78049abac123332123990994b50a70bc789b7514 (diff)
parentacd511f6767cdcc332851e44a62fbd843399446a (diff)
downloadmitmproxy-c89c4361c376765c666cc6ed0ab5834b2418082d.tar.gz
mitmproxy-c89c4361c376765c666cc6ed0ab5834b2418082d.tar.bz2
mitmproxy-c89c4361c376765c666cc6ed0ab5834b2418082d.zip
Merge remote-tracking branch 'alts/encoding'
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r--libmproxy/proxy.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index e765d8b6..e19577ef 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -428,6 +428,27 @@ class Response(controller.Msg):
c += self.headers.replace(pattern, repl, *args, **kwargs)
return c
+ def decode(self):
+ """
+ Alters Response object, decoding its content based on the current
+ Content-Encoding header and changing Content-Encoding header to
+ 'identity'.
+ """
+ self.content = encoding.decode(
+ (self.headers["content-encoding"] or ["identity"])[0],
+ self.content
+ )
+ self.headers["content-encoding"] = ["identity"]
+
+ def encode(self, e):
+ """
+ Alters Response object, encoding its content with the specified
+ coding. This method should only be called on Responses with
+ Content-Encoding headers of 'identity'.
+ """
+ self.content = encoding.encode(e, self.content)
+ self.headers["content-encoding"] = [e]
+
class ClientDisconnect(controller.Msg):
def __init__(self, client_conn):