mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-11-10 18:36:33 +00:00
Fixed http fallback
This commit is contained in:
parent
014ee602ef
commit
10e79bbbad
2 changed files with 25 additions and 6 deletions
|
|
@ -386,7 +386,22 @@ class API(object):
|
|||
LOG.debug(request_settings['timeout'])
|
||||
LOG.debug(request_settings['headers'])
|
||||
|
||||
try:
|
||||
return request_method(url, **request_settings)
|
||||
except requests.exceptions.SSLError as e:
|
||||
LOG.error("Failed to connect to server. SSL Issue: %s" % e)
|
||||
response = requests.Response()
|
||||
response.code = "SSL Error: %s".format(e)
|
||||
response.error_type = "SSLError"
|
||||
response.status_code = 500
|
||||
return response
|
||||
except Exception as e:
|
||||
LOG.error("Failed to connect to server. Unhandled Issue: %s" % e)
|
||||
response = requests.Response()
|
||||
response.code = e
|
||||
response.error_type = "UnhandledError"
|
||||
response.status_code = 500
|
||||
return response
|
||||
|
||||
|
||||
def login(self, server_url, username, password=""):
|
||||
|
|
|
|||
|
|
@ -134,6 +134,10 @@ class ConnectionManager(object):
|
|||
|
||||
try:
|
||||
public_info = self.API.get_public_info(address)
|
||||
if not public_info:
|
||||
LOG.error("connectToAddress %s failed", address)
|
||||
return { 'State': CONNECTION_STATE['Unavailable'] }
|
||||
|
||||
LOG.info("connectToAddress %s succeeded", address)
|
||||
server = {
|
||||
'address': address,
|
||||
|
|
@ -291,13 +295,13 @@ class ConnectionManager(object):
|
|||
|
||||
# Test if server is reachable over https
|
||||
if self.API.get_public_info(url):
|
||||
if url.scheme == 'https' and url.port == 443:
|
||||
if url.port == 443:
|
||||
url = url._replace(port=None)
|
||||
else:
|
||||
# Server didn't give an expected response over https
|
||||
# Try http instead
|
||||
url._replace(scheme='http')
|
||||
if url.scheme == 'http' and url.port == 80:
|
||||
url = url._replace(scheme='http')
|
||||
if url.port == 80:
|
||||
url = url._replace(port=None)
|
||||
|
||||
return url.url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue