Add curl-like --insecure option to REST
This commit is contained in:
parent
b28cf6689a
commit
5f0e27a880
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user