From 0a556adbfab8d6cd673f0be137dac694af58350f Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Fri, 21 Jul 2017 12:27:34 +0200 Subject: [PATCH] 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.. --- python_apps/pypo/pypo/pypofile.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python_apps/pypo/pypo/pypofile.py b/python_apps/pypo/pypo/pypofile.py index 8bb7a054e..df7e4f12d 100644 --- a/python_apps/pypo/pypo/pypofile.py +++ b/python_apps/pypo/pypo/pypofile.py @@ -64,8 +64,12 @@ class PypoFile(Thread): username = self._config.get(CONFIG_SECTION, 'api_key') host = self._config.get(CONFIG_SECTION, 'base_url') 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: response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True, verify=False)