mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Add pathoc -o, oneshot mode, exits after the first non-ignored response.
This commit is contained in:
parent
7209a75201
commit
65108ed429
@ -49,6 +49,8 @@ class Pathoc(tcp.TCPClient):
|
||||
explain: Print request explanation
|
||||
hexdump: When printing requests or responses, use hex dump output
|
||||
ignorecodes: Sequence of return codes to ignore
|
||||
|
||||
Returns True if we have a non-ignored response.
|
||||
"""
|
||||
try:
|
||||
r = rparse.parse_request(self.settings, spec)
|
||||
@ -94,3 +96,4 @@ class Pathoc(tcp.TCPClient):
|
||||
else:
|
||||
if resp:
|
||||
self._show_summary(fp, *resp)
|
||||
return True
|
||||
|
10
pathoc
10
pathoc
@ -36,12 +36,16 @@ if __name__ == "__main__":
|
||||
group = parser.add_argument_group('Controlling Output')
|
||||
group.add_argument(
|
||||
"-c", dest="ignorecodes", type=str, default="",
|
||||
help="Comma-separated list of response codes filter"
|
||||
help="Comma-separated list of response codes to ignore"
|
||||
)
|
||||
group.add_argument(
|
||||
"-e", dest="explain", action="store_true", default=False,
|
||||
help="Explain requests"
|
||||
)
|
||||
group.add_argument(
|
||||
"-o", dest="oneshot", action="store_true", default=False,
|
||||
help="Oneshot - exit after first non-ignored response"
|
||||
)
|
||||
group.add_argument(
|
||||
"-q", dest="showreq", action="store_true", default=False,
|
||||
help="Print full request"
|
||||
@ -84,7 +88,7 @@ if __name__ == "__main__":
|
||||
if args.timeout:
|
||||
p.settimeout(args.timeout)
|
||||
for spec in args.request:
|
||||
p.print_request(
|
||||
ret = p.print_request(
|
||||
spec,
|
||||
showreq=args.showreq,
|
||||
showresp=args.showresp,
|
||||
@ -93,6 +97,8 @@ if __name__ == "__main__":
|
||||
ignorecodes=codes
|
||||
)
|
||||
sys.stdout.flush()
|
||||
if ret and args.oneshot:
|
||||
sys.exit(0)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user