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