aboutsummaryrefslogtreecommitdiffstats
path: root/pathoc
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-24 21:10:10 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-24 21:10:10 +1200
commit90c6fb394de8b56c55aee3db7c7ea6ff72903456 (patch)
tree5985fc18ad5b384c6bc55af831c037fdc18ec187 /pathoc
parent8bec99f858deb8aaf35b6502355e3e00a98ffed7 (diff)
downloadmitmproxy-90c6fb394de8b56c55aee3db7c7ea6ff72903456.tar.gz
mitmproxy-90c6fb394de8b56c55aee3db7c7ea6ff72903456.tar.bz2
mitmproxy-90c6fb394de8b56c55aee3db7c7ea6ff72903456.zip
Sketch out pathoc commandline interaction.
Diffstat (limited to 'pathoc')
-rwxr-xr-xpathoc25
1 files changed, 25 insertions, 0 deletions
diff --git a/pathoc b/pathoc
new file mode 100755
index 00000000..12edc34a
--- /dev/null
+++ b/pathoc
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import argparse, sys
+from libpathod import pathoc, version
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='A perverse HTTP client.')
+ parser.add_argument('--port', type=int, default=None, help="Port. Defaults to 80, or 443 if SSL is active.")
+ parser.add_argument('--ssl', action="store_true", default=False, help="Connect with SSL.")
+ parser.add_argument('host', type=str, help='Host to connect to')
+ parser.add_argument('request', type=str, nargs="+", help='Request specification')
+
+ args = parser.parse_args()
+
+ if args.port is None:
+ port = 443 if args.ssl else 80
+ else:
+ port = args.port
+
+ try:
+ p = pathoc.Pathoc(args.ssl, args.host, port, None)
+ for i in args.request:
+ p.request(i)
+ except pathoc.PathocError, v:
+ print >> sys.stderr, str(v)
+ sys.exit(1)