diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-26 10:15:11 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-26 10:15:11 +1200 |
commit | f32258e8f7eb2f4b43a704a003f00c32efbb898c (patch) | |
tree | 66cb3057f2092c893fef1c3c1d84f233462d213d /pathoc | |
parent | 8352c0278f468be30a9765a61f369ceb317aafe9 (diff) | |
download | mitmproxy-f32258e8f7eb2f4b43a704a003f00c32efbb898c.tar.gz mitmproxy-f32258e8f7eb2f4b43a704a003f00c32efbb898c.tar.bz2 mitmproxy-f32258e8f7eb2f4b43a704a003f00c32efbb898c.zip |
Port pathoc to new netlib API. Add SNI.
Diffstat (limited to 'pathoc')
-rwxr-xr-x | pathoc | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,11 +1,12 @@ #!/usr/bin/env python import argparse, sys -from libpathod import pathoc, version +from libpathod import pathoc, version, rparse if __name__ == "__main__": parser = argparse.ArgumentParser(description='A perverse HTTP client.') parser.add_argument('--port', "-p", type=int, default=None, help="Port. Defaults to 80, or 443 if SSL is active.") parser.add_argument('--ssl', "-s", action="store_true", default=False, help="Connect with SSL.") + parser.add_argument('--sni', "-n", type=str, default=False, help="SSL Server Name Indication.") parser.add_argument('--verbose', '-v', action='count') parser.add_argument('host', type=str, help='Host to connect to') parser.add_argument('request', type=str, nargs="+", help='Request specification') @@ -17,16 +18,21 @@ if __name__ == "__main__": else: port = args.port - try: - p = pathoc.Pathoc(args.ssl, args.host, port, None) + p = pathoc.Pathoc(args.host, port) + p.connect() + if args.ssl: + p.convert_to_ssl(sni=args.sni) for i in args.request: ret = p.request(i) if args.verbose: pathoc.print_full(sys.stdout, *ret) else: pathoc.print_short(sys.stdout, *ret) - except pathoc.PathocError, v: print >> sys.stderr, str(v) sys.exit(1) + except rparse.ParseException, v: + print >> sys.stderr, "Error parsing request spec: %s"%v.msg + print >> sys.stderr, v.marked() + sys.exit(1) |