Use proper protocol in URL if port is set to 443
This adds TLS support to pypo when downloading files from the REST API. I previously fixed some similar issues in the api_client and wasn't aware that pypo isn't using it for every URL..
This commit is contained in:
parent
6e2cb2b2a8
commit
0a556adbfa
1 changed files with 6 additions and 2 deletions
|
@ -64,8 +64,12 @@ class PypoFile(Thread):
|
||||||
username = self._config.get(CONFIG_SECTION, 'api_key')
|
username = self._config.get(CONFIG_SECTION, 'api_key')
|
||||||
host = self._config.get(CONFIG_SECTION, 'base_url')
|
host = self._config.get(CONFIG_SECTION, 'base_url')
|
||||||
port = self._config.get(CONFIG_SECTION, 'base_port', 80)
|
port = self._config.get(CONFIG_SECTION, 'base_port', 80)
|
||||||
url = "http://%s:%s/rest/media/%s/download" % (host, port, media_item["id"])
|
|
||||||
self.logger.error(url)
|
url = "%s://%s:%s/rest/media/%s/download" % (str(("http", "https")[int(port) == 443]),
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
media_item["id"])
|
||||||
|
self.logger.info(url)
|
||||||
with open(dst, "wb") as handle:
|
with open(dst, "wb") as handle:
|
||||||
response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True, verify=False)
|
response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True, verify=False)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue