Add support for client timeout to pathoc.
This commit is contained in:
parent
72e30d4712
commit
059a232903
|
@ -45,7 +45,10 @@ class Pathoc(tcp.TCPClient):
|
||||||
except http.HttpError, v:
|
except http.HttpError, v:
|
||||||
print >> fp, v.msg
|
print >> fp, v.msg
|
||||||
return
|
return
|
||||||
if verbose:
|
except tcp.NetLibTimeout:
|
||||||
print_full(fp, *ret)
|
print >> fp, "Timeout"
|
||||||
else:
|
else:
|
||||||
print_short(fp, *ret)
|
if verbose:
|
||||||
|
print_full(fp, *ret)
|
||||||
|
else:
|
||||||
|
print_short(fp, *ret)
|
||||||
|
|
10
pathoc
10
pathoc
|
@ -5,6 +5,10 @@ from netlib import tcp
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description='A perverse HTTP client.')
|
parser = argparse.ArgumentParser(description='A perverse HTTP client.')
|
||||||
|
parser.add_argument(
|
||||||
|
"-i", dest="sni", type=str, default=False,
|
||||||
|
help="SSL Server Name Indication."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-n", dest='repeat', default=1, type=int, metavar="N",
|
"-n", dest='repeat', default=1, type=int, metavar="N",
|
||||||
help='Repeat requests N times.'
|
help='Repeat requests N times.'
|
||||||
|
@ -18,8 +22,8 @@ if __name__ == "__main__":
|
||||||
help="Connect with SSL."
|
help="Connect with SSL."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-i", dest="sni", type=str, default=False,
|
"-t", dest="timeout", type=int, default=None,
|
||||||
help="SSL Server Name Indication."
|
help="Connection timeout."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v", dest="verbose", action='count',
|
"-v", dest="verbose", action='count',
|
||||||
|
@ -50,4 +54,6 @@ if __name__ == "__main__":
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if args.ssl:
|
if args.ssl:
|
||||||
p.convert_to_ssl(sni=args.sni)
|
p.convert_to_ssl(sni=args.sni)
|
||||||
|
if args.timeout:
|
||||||
|
p.settimeout(args.timeout)
|
||||||
p.print_requests(args.request, args.verbose)
|
p.print_requests(args.request, args.verbose)
|
||||||
|
|
Loading…
Reference in New Issue