Skip to content

Instantly share code, notes, and snippets.

@fernyb
Created November 28, 2014 00:31
Show Gist options
  • Save fernyb/18a6654c1a526138367f to your computer and use it in GitHub Desktop.
Save fernyb/18a6654c1a526138367f to your computer and use it in GitHub Desktop.
mitmproxy (mitmdump) script to print response body
import sys
import cStringIO
from PIL import Image
from libmproxy.protocol.http import decoded
def response(context, flow):
content_type = flow.response.headers.get_first("content-type", "")
sys.stdout.write("Content Type: "+ content_type +"\n\n")
if content_type.startswith("text"):
sys.stdout.write("Response Content: "+ flow.response.content +"\n\n")
# with decoded(flow.response):
# try:
# s = cStringIO.StringIO(flow.response.content)
# sys.stdout.write("Response Content: "+ s +"\n\n")
# except:
# pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment