diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-02 02:01:46 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-07-02 02:01:46 -0700 |
commit | dbf7cb1a442e2c0823d853ca310395048496996d (patch) | |
tree | 2e6fa840f1b4f41f8a348a21569ddedf4a213668 /examples/upsidedownternet.py | |
parent | 6032c4f2352260d32032800a2ff694339e2af6b2 (diff) | |
download | mitmproxy-dbf7cb1a442e2c0823d853ca310395048496996d.tar.gz mitmproxy-dbf7cb1a442e2c0823d853ca310395048496996d.tar.bz2 mitmproxy-dbf7cb1a442e2c0823d853ca310395048496996d.zip |
update examples: no decoded() anymore :tada:
Diffstat (limited to 'examples/upsidedownternet.py')
-rw-r--r-- | examples/upsidedownternet.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/upsidedownternet.py b/examples/upsidedownternet.py index 9aac9f05..58ed53d7 100644 --- a/examples/upsidedownternet.py +++ b/examples/upsidedownternet.py @@ -1,17 +1,15 @@ from six.moves import cStringIO as StringIO from PIL import Image -from mitmproxy.models import decoded def response(context, flow): if flow.response.headers.get("content-type", "").startswith("image"): - with decoded(flow.response): # automatically decode gzipped responses. - try: - s = StringIO(flow.response.content) - img = Image.open(s).rotate(180) - s2 = StringIO() - img.save(s2, "png") - flow.response.content = s2.getvalue() - flow.response.headers["content-type"] = "image/png" - except: # Unknown image types etc. - pass + try: + s = StringIO(flow.response.content) + img = Image.open(s).rotate(180) + s2 = StringIO() + img.save(s2, "png") + flow.response.content = s2.getvalue() + flow.response.headers["content-type"] = "image/png" + except: # Unknown image types etc. + pass |