mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-11-22 10:23:50 +01:00
Merge pull request #77 from K0nne/patch-1
fix missing type conversion for --data
This commit is contained in:
commit
2e6eaeea59
@ -599,13 +599,15 @@ def main(cliargs):
|
|||||||
for header in headers:
|
for header in headers:
|
||||||
req.add_header(header, headers[header])
|
req.add_header(header, headers[header])
|
||||||
if args.timeout and args.data:
|
if args.timeout and args.data:
|
||||||
|
databytes = str(args.data).encode()
|
||||||
response = urllib.request.urlopen(req, timeout=args.timeout,
|
response = urllib.request.urlopen(req, timeout=args.timeout,
|
||||||
data=args.data, context=context)
|
data=databytes, context=context)
|
||||||
elif args.timeout:
|
elif args.timeout:
|
||||||
response = urllib.request.urlopen(req, timeout=args.timeout,
|
response = urllib.request.urlopen(req, timeout=args.timeout,
|
||||||
context=context)
|
context=context)
|
||||||
elif args.data:
|
elif args.data:
|
||||||
response = urllib.request.urlopen(req, data=args.data, context=context)
|
databytes = str(args.data).encode()
|
||||||
|
response = urllib.request.urlopen(req, data=databytes, context=context)
|
||||||
else:
|
else:
|
||||||
response = urllib.request.urlopen(req, context=context)
|
response = urllib.request.urlopen(req, context=context)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user