Replace deprecated encodestring

- Fixes #56
This commit is contained in:
Markus Opolka 2020-03-18 08:47:27 +01:00
parent 83ee5062f5
commit dd952fd571

View File

@ -585,8 +585,8 @@ if __name__ == "__main__":
req = urllib.request.Request(url) req = urllib.request.Request(url)
req.add_header("User-Agent", "check_http_json") req.add_header("User-Agent", "check_http_json")
if args.auth: if args.auth:
# TODO: replace deprecated encodestring authbytes = str(args.auth).encode()
base64str = base64.encodestring(args.auth).replace('\n', '') base64str = base64.encodebytes(authbytes).decode().replace('\n', '')
req.add_header('Authorization', 'Basic %s' % base64str) req.add_header('Authorization', 'Basic %s' % base64str)
if args.headers: if args.headers:
headers = json.loads(args.headers) headers = json.loads(args.headers)