mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Add pathoc -T to ignore timeouts.
Also move -c to -C for consistency.
This commit is contained in:
parent
65108ed429
commit
8bb81be2b0
@ -38,7 +38,7 @@ 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, ignorecodes, fp=sys.stdout):
|
||||
def print_request(self, spec, showreq, showresp, explain, hexdump, ignorecodes, ignoretimeout, fp=sys.stdout):
|
||||
"""
|
||||
Performs a series of requests, and prints results to the specified
|
||||
file descriptor.
|
||||
@ -74,6 +74,8 @@ class Pathoc(tcp.TCPClient):
|
||||
except http.HttpError, v:
|
||||
print >> fp, "<< HTTP Error:", v.msg
|
||||
except tcp.NetLibTimeout:
|
||||
if ignoretimeout:
|
||||
return
|
||||
print >> fp, "<<", "Timeout"
|
||||
except tcp.NetLibDisconnect: # pragma: nocover
|
||||
print >> fp, "<<", "Disconnect"
|
||||
|
9
pathoc
9
pathoc
@ -35,7 +35,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
group = parser.add_argument_group('Controlling Output')
|
||||
group.add_argument(
|
||||
"-c", dest="ignorecodes", type=str, default="",
|
||||
"-C", dest="ignorecodes", type=str, default="",
|
||||
help="Comma-separated list of response codes to ignore"
|
||||
)
|
||||
group.add_argument(
|
||||
@ -54,6 +54,10 @@ if __name__ == "__main__":
|
||||
"-r", dest="showresp", action="store_true", default=False,
|
||||
help="Print full response"
|
||||
)
|
||||
group.add_argument(
|
||||
"-T", dest="ignoretimeout", action="store_true", default=False,
|
||||
help="Ignore timeouts"
|
||||
)
|
||||
group.add_argument(
|
||||
"-x", dest="hexdump", action="store_true", default=False,
|
||||
help="Output in hexdump format"
|
||||
@ -94,7 +98,8 @@ if __name__ == "__main__":
|
||||
showresp=args.showresp,
|
||||
explain=args.explain,
|
||||
hexdump=args.hexdump,
|
||||
ignorecodes=codes
|
||||
ignorecodes=codes,
|
||||
ignoretimeout=args.ignoretimeout
|
||||
)
|
||||
sys.stdout.flush()
|
||||
if ret and args.oneshot:
|
||||
|
@ -24,7 +24,7 @@ class TestDaemon:
|
||||
_, _, _, _, content = c.request("get:/api/info")
|
||||
assert tuple(json.loads(content)["version"]) == version.IVERSION
|
||||
|
||||
def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None):
|
||||
def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None):
|
||||
c = pathoc.Pathoc("127.0.0.1", self.d.port)
|
||||
c.connect()
|
||||
if timeout:
|
||||
@ -38,6 +38,7 @@ class TestDaemon:
|
||||
explain = explain,
|
||||
hexdump = hexdump,
|
||||
ignorecodes = ignorecodes,
|
||||
ignoretimeout = ignoretimeout,
|
||||
fp = s
|
||||
)
|
||||
return s.getvalue()
|
||||
|
Loading…
Reference in New Issue
Block a user