diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2012-09-26 10:38:47 +1200 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2012-09-26 10:38:47 +1200 |
| commit | a69d60208717db775ca68bbd1cd8a1af76082495 (patch) | |
| tree | 2ebc4a62666079d61e2bb30616f5217460612cce /libpathod | |
| parent | 0a5d4fbbbb06a4e6c5e6172b353aa878aaa6e0c6 (diff) | |
| download | mitmproxy-a69d60208717db775ca68bbd1cd8a1af76082495.tar.gz mitmproxy-a69d60208717db775ca68bbd1cd8a1af76082495.tar.bz2 mitmproxy-a69d60208717db775ca68bbd1cd8a1af76082495.zip | |
Hex and verbatim output of requests.
This works by sniffing traffic through the socket, so always gives us the exact
traffic sent upstream.
Diffstat (limited to 'libpathod')
| -rw-r--r-- | libpathod/pathoc.py | 15 | ||||
| -rw-r--r-- | libpathod/rparse.py | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 57bff46b..b283c94e 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -1,5 +1,6 @@ import sys, os from netlib import tcp, http +import netlib.utils import rparse, utils class PathocError(Exception): pass @@ -49,15 +50,25 @@ class Pathoc(tcp.TCPClient): for i in reqs: try: r = rparse.parse_request(self.settings, i) + if showreq: + self.wfile.start_log() req = r.serve(self.wfile, None, self.host) if explain: - print >> fp, ">>", req["method"], repr(req["path"]) + print >> fp, ">> ", req["method"], repr(req["path"]) for a in req["actions"]: print >> fp, "\t", for x in a: print >> fp, x, print >> fp - print req + if showreq: + data = self.wfile.get_log() + if hexdump: + print >> fp, ">> Request (hex dump):" + for line in netlib.utils.hexdump(data): + print >> fp, "\t%s %s %s"%line + else: + print >> fp, ">> Request (unprintables escaped):" + print >> fp, netlib.utils.cleanBin(data) self.wfile.flush() resp = http.read_response(self.rfile, r.method, None) except rparse.ParseException, v: diff --git a/libpathod/rparse.py b/libpathod/rparse.py index 3eaf2569..53878b97 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -653,7 +653,7 @@ class Response(Message): ShortcutLocation, Raw ) - logattrs = ["code", "version"] + logattrs = ["code", "version", "body"] def __init__(self): Message.__init__(self) self.code = 200 @@ -691,7 +691,7 @@ class Request(Message): ShortcutContentType, Raw ) - logattrs = ["method", "path"] + logattrs = ["method", "path", "body"] def __init__(self): Message.__init__(self) self.method = None |
