mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-11-10 18:36:33 +00:00
Updated address normalization to test for https first to fix #223
This commit is contained in:
parent
881c0e947a
commit
014ee602ef
1 changed files with 12 additions and 11 deletions
|
|
@ -283,21 +283,22 @@ class ConnectionManager(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _normalize_address(self, address):
|
def _normalize_address(self, address):
|
||||||
# TODO: Try HTTPS first, then HTTP if that fails.
|
|
||||||
if '://' not in address:
|
|
||||||
address = 'http://' + address
|
|
||||||
|
|
||||||
# Attempt to correct bad input
|
# Attempt to correct bad input
|
||||||
url = urllib3.util.parse_url(address.strip())
|
url = urllib3.util.parse_url(address.strip())
|
||||||
|
|
||||||
if url.scheme is None:
|
# Default to using https
|
||||||
url = url._replace(scheme='http')
|
url = url._replace(scheme='https')
|
||||||
|
|
||||||
if url.scheme == 'http' and url.port == 80:
|
# Test if server is reachable over https
|
||||||
url = url._replace(port=None)
|
if self.API.get_public_info(url):
|
||||||
|
if url.scheme == 'https' and url.port == 443:
|
||||||
if url.scheme == 'https' and url.port == 443:
|
url = url._replace(port=None)
|
||||||
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(port=None)
|
||||||
|
|
||||||
return url.url
|
return url.url
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue