1
0

Add curl-like --insecure option to REST

This commit is contained in:
Noah 2016-08-12 14:10:58 -07:00
parent b28cf6689a
commit 5f0e27a880

View File

@ -49,6 +49,11 @@ def main():
default=None,
help="JSON data to be sent with the request.",
)
parser.add_argument(
"--insecure", "-k",
action="store_true",
help="Don't validate SSL certificates.",
)
parser.add_argument(
"method",
help="The HTTP method to use",
@ -78,11 +83,16 @@ def do_http(args):
if args.header:
headers.update(args.header)
ssl_opts = {}
if args.insecure:
ssl_opts.update(verify=False)
result = getattr(requests, args.method.lower())(
args.url,
headers=headers,
cookies=args.cookie,
data=args.data,
**ssl_opts
)
print(args.method, args.url, result.status_code)