aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpathod/cmdline.py17
-rw-r--r--libpathod/pathoc.py9
2 files changed, 19 insertions, 7 deletions
diff --git a/libpathod/cmdline.py b/libpathod/cmdline.py
index 3b1a86bf..a21fa218 100644
--- a/libpathod/cmdline.py
+++ b/libpathod/cmdline.py
@@ -36,7 +36,14 @@ def go_pathoc():
)
parser.add_argument(
"-n", dest='repeat', default=1, type=int, metavar="N",
- help='Repeat requests N times'
+ help='Repeat N times'
+ )
+ parser.add_argument(
+ "-r", dest="random", action="store_true", default=False,
+ help="""
+ Select a random request from those specified. If this is not specified,
+ requests are all played in sequence.
+ """
)
parser.add_argument(
"-t", dest="timeout", type=int, default=None,
@@ -48,7 +55,7 @@ def go_pathoc():
help='Host and port to connect to'
)
parser.add_argument(
- 'request', type=str, nargs="+",
+ 'requests', type=str, nargs="+",
help="""
Request specification, or path to a file containing request
specifcations
@@ -110,7 +117,7 @@ def go_pathoc():
help="Print full request"
)
group.add_argument(
- "-r", dest="showresp", action="store_true", default=False,
+ "-p", dest="showresp", action="store_true", default=False,
help="Print full response"
)
group.add_argument(
@@ -155,7 +162,7 @@ def go_pathoc():
args.connect_to = None
reqs = []
- for r in args.request:
+ for r in args.requests:
if os.path.exists(r):
data = open(r).read()
r = data
@@ -165,7 +172,7 @@ def go_pathoc():
print >> sys.stderr, "Error parsing request spec: %s"%v.msg
print >> sys.stderr, v.marked()
sys.exit(1)
- args.request = reqs
+ args.requests = reqs
pathoc.main(args)
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index b9b202eb..c85c207a 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -1,5 +1,6 @@
import sys
import os
+import random
from netlib import tcp, http, certutils
import netlib.utils
@@ -189,7 +190,7 @@ class Pathoc(tcp.TCPClient):
if resp:
self._show_summary(fp, *resp)
- if self.sslinfo:
+ if showssl and self.sslinfo:
print >> fp, "Cipher: %s, %s bit, %s"%self.sslinfo.cipher
print >> fp, "SSL certificate chain:\n"
for i in self.sslinfo.certchain:
@@ -239,7 +240,11 @@ def main(args):
sys.exit(1)
if args.timeout:
p.settimeout(args.timeout)
- for spec in args.request:
+ if args.random:
+ playlist = [random.choice(args.requests)]
+ else:
+ playlist = args.requests
+ for spec in playlist:
ret = p.print_request(
spec,
showreq=args.showreq,