Add curl-like --insecure option to REST
This commit is contained in:
parent
b28cf6689a
commit
5f0e27a880
|
@ -49,6 +49,11 @@ def main():
|
||||||
default=None,
|
default=None,
|
||||||
help="JSON data to be sent with the request.",
|
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(
|
parser.add_argument(
|
||||||
"method",
|
"method",
|
||||||
help="The HTTP method to use",
|
help="The HTTP method to use",
|
||||||
|
@ -78,11 +83,16 @@ def do_http(args):
|
||||||
if args.header:
|
if args.header:
|
||||||
headers.update(args.header)
|
headers.update(args.header)
|
||||||
|
|
||||||
|
ssl_opts = {}
|
||||||
|
if args.insecure:
|
||||||
|
ssl_opts.update(verify=False)
|
||||||
|
|
||||||
result = getattr(requests, args.method.lower())(
|
result = getattr(requests, args.method.lower())(
|
||||||
args.url,
|
args.url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
cookies=args.cookie,
|
cookies=args.cookie,
|
||||||
data=args.data,
|
data=args.data,
|
||||||
|
**ssl_opts
|
||||||
)
|
)
|
||||||
|
|
||||||
print(args.method, args.url, result.status_code)
|
print(args.method, args.url, result.status_code)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user