Change site services tester to fallback to http if error with SSL.

This commit is contained in:
JackDandy 2018-09-13 04:05:39 +01:00
parent d0a96c3345
commit 8c69a48975
2 changed files with 14 additions and 1 deletions

View file

@ -13,6 +13,7 @@
* Change if old scandir binary module is installed, fallback to slow Python module and inform user to upgrade binary * Change if old scandir binary module is installed, fallback to slow Python module and inform user to upgrade binary
* Update SimpleJSON 3.13.2 (6ffddbe) to 3.16.0 (e2a54f7) * Update SimpleJSON 3.13.2 (6ffddbe) to 3.16.0 (e2a54f7)
* Update unidecode module 1.0.22 (81f938d) to 1.0.22 (578cdb9) * Update unidecode module 1.0.22 (81f938d) to 1.0.22 (578cdb9)
* Change site services tester to fallback to http if error with SSL
[develop changelog] [develop changelog]

View file

@ -5347,7 +5347,19 @@ class History(MainHandler):
result = {} result = {}
if site_url: if site_url:
resp = helpers.getURL('https://www.isitdownrightnow.com/check.php?domain=%s' % site_url) import requests
down_url = 'www.isitdownrightnow.com'
proto = 'https'
try:
requests.head('%s://%s' % (proto, down_url), timeout=5)
except (StandardError, Exception):
proto = 'http'
try:
requests.head('%s://%s' % (proto, down_url), timeout=5)
except (StandardError, Exception):
return json.dumps(result)
resp = helpers.getURL('%s://%s/check.php?domain=%s' % (proto, down_url, site_url))
if resp: if resp:
check = resp.lower() check = resp.lower()
day = re.findall(r'(\d+)\s*(?:day)', check) day = re.findall(r'(\d+)\s*(?:day)', check)