aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathoc.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-09-27 09:44:25 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-09-27 09:44:25 +1200
commit7209a75201a25d7ec2448c6ad1a871c0c403c97e (patch)
treeb5986b17db4c81e5501e1837f8a78fd76ca39018 /libpathod/pathoc.py
parent10a19fc4da5a6fbbfd4a36d0e61d3bc80a38e937 (diff)
downloadmitmproxy-7209a75201a25d7ec2448c6ad1a871c0c403c97e.tar.gz
mitmproxy-7209a75201a25d7ec2448c6ad1a871c0c403c97e.tar.bz2
mitmproxy-7209a75201a25d7ec2448c6ad1a871c0c403c97e.zip
Add pathoc -c to specify a list of return codes to ignore.
Diffstat (limited to 'libpathod/pathoc.py')
-rw-r--r--libpathod/pathoc.py40
1 files changed, 23 insertions, 17 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index 40f698fd..0cc0466d 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -38,16 +38,17 @@ class Pathoc(tcp.TCPClient):
print >> fp, "%s (unprintables escaped):"%header
print >> fp, netlib.utils.cleanBin(data)
- def print_request(self, spec, showreq, showresp, explain, hexdump, fp=sys.stdout):
+ def print_request(self, spec, showreq, showresp, explain, hexdump, ignorecodes, fp=sys.stdout):
"""
Performs a series of requests, and prints results to the specified
file descriptor.
- reqs: A sequence of request specifications
+ spec: A request specification
showreq: Print requests
showresp: Print responses
explain: Print request explanation
hexdump: When printing requests or responses, use hex dump output
+ ignorecodes: Sequence of return codes to ignore
"""
try:
r = rparse.parse_request(self.settings, spec)
@@ -59,20 +60,11 @@ class Pathoc(tcp.TCPClient):
print >> fp, "File access error: %s"%v
return
- resp = None
+ resp, req = None, None
if showreq:
self.wfile.start_log()
try:
req = r.serve(self.wfile, None, self.host)
- if explain:
- print >> fp, ">> ", req["method"], repr(req["path"])
- for a in req["actions"]:
- print >> fp, "\t",
- for x in a:
- print >> fp, x,
- print >> fp
- if showreq:
- self._show(fp, ">> Request", self.wfile.get_log(), hexdump)
self.wfile.flush()
if showresp:
self.rfile.start_log()
@@ -83,8 +75,22 @@ class Pathoc(tcp.TCPClient):
print >> fp, "<<", "Timeout"
except tcp.NetLibDisconnect: # pragma: nocover
print >> fp, "<<", "Disconnect"
- if showresp:
- self._show(fp, "<< Response", self.rfile.get_log(), hexdump)
- else:
- if resp:
- self._show_summary(fp, *resp)
+
+ if req:
+ if ignorecodes and resp and resp[1] in ignorecodes:
+ return
+ if explain:
+ print >> fp, ">>", req["method"], repr(req["path"])
+ for a in req["actions"]:
+ print >> fp, "\t",
+ for x in a:
+ print >> fp, x,
+ print >> fp
+ if showreq:
+ self._show(fp, ">> Request", self.wfile.get_log(), hexdump)
+
+ if showresp:
+ self._show(fp, "<< Response", self.rfile.get_log(), hexdump)
+ else:
+ if resp:
+ self._show_summary(fp, *resp)