handle missing api header

This commit is contained in:
Kevin Froman 2018-10-27 14:59:15 -05:00
parent c073020b80
commit 4e86604692

View File

@ -616,8 +616,11 @@ class OnionrUtils:
proxies = {'http': 'socks4a://127.0.0.1:' + str(port), 'https': 'socks4a://127.0.0.1:' + str(port)} 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)) r = requests.get(url, headers=headers, proxies=proxies, allow_redirects=False, timeout=(15, 30))
# Check server is using same API version as us # Check server is using same API version as us
try:
if r.headers['api'] != str(API_VERSION): if r.headers['api'] != str(API_VERSION):
raise onionrexceptions.InvalidAPIVersion raise onionrexceptions.InvalidAPIVersion
except KeyError:
raise onionrexceptions.InvalidAPIVersion
retData = r.text retData = r.text
except KeyboardInterrupt: except KeyboardInterrupt:
raise KeyboardInterrupt raise KeyboardInterrupt