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['timeout'])
|
||||||
LOG.debug(request_settings['headers'])
|
LOG.debug(request_settings['headers'])
|
||||||
|
|
||||||
return request_method(url, **request_settings)
|
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=""):
|
def login(self, server_url, username, password=""):
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,10 @@ class ConnectionManager(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
public_info = self.API.get_public_info(address)
|
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)
|
LOG.info("connectToAddress %s succeeded", address)
|
||||||
server = {
|
server = {
|
||||||
'address': address,
|
'address': address,
|
||||||
|
|
@ -286,18 +290,18 @@ class ConnectionManager(object):
|
||||||
# Attempt to correct bad input
|
# Attempt to correct bad input
|
||||||
url = urllib3.util.parse_url(address.strip())
|
url = urllib3.util.parse_url(address.strip())
|
||||||
|
|
||||||
# Default to using https
|
# Default to using https
|
||||||
url = url._replace(scheme='https')
|
url = url._replace(scheme='https')
|
||||||
|
|
||||||
# Test if server is reachable over https
|
# Test if server is reachable over https
|
||||||
if self.API.get_public_info(url):
|
if self.API.get_public_info(url):
|
||||||
if url.scheme == 'https' and url.port == 443:
|
if url.port == 443:
|
||||||
url = url._replace(port=None)
|
url = url._replace(port=None)
|
||||||
else:
|
else:
|
||||||
# Server didn't give an expected response over https
|
# Server didn't give an expected response over https
|
||||||
# Try http instead
|
# Try http instead
|
||||||
url._replace(scheme='http')
|
url = url._replace(scheme='http')
|
||||||
if url.scheme == 'http' and url.port == 80:
|
if url.port == 80:
|
||||||
url = url._replace(port=None)
|
url = url._replace(port=None)
|
||||||
|
|
||||||
return url.url
|
return url.url
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue