From 4e86604692f837fbcfe5fdf8310304318672e0d0 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 27 Oct 2018 14:59:15 -0500 Subject: [PATCH] handle missing api header --- onionr/onionrutils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 5cc79e90..f102a3a1 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -616,7 +616,10 @@ class OnionrUtils: proxies = {'http': 'socks4a://127.0.0.1:' + str(port), 'https': 'socks4a://127.0.0.1:' + str(port)} r = requests.get(url, headers=headers, proxies=proxies, allow_redirects=False, timeout=(15, 30)) # Check server is using same API version as us - if r.headers['api'] != str(API_VERSION): + try: + if r.headers['api'] != str(API_VERSION): + raise onionrexceptions.InvalidAPIVersion + except KeyError: raise onionrexceptions.InvalidAPIVersion retData = r.text except KeyboardInterrupt: