Browse code

Set public_url() protocol based on use_https

If use_https is true, prefix public URLs with https. Otherwise use
http as before.

Jukka Nousiainen authored on 2019/02/28 22:33:21
Showing 1 changed files
... ...
@@ -90,10 +90,13 @@ class S3UriS3(S3Uri):
90 90
         return check_bucket_name_dns_support(Config.Config().host_bucket, self._bucket)
91 91
 
92 92
     def public_url(self):
93
+        public_url_protocol = "http"
94
+        if Config.Config().use_https:
95
+            public_url_protocol = "https"
93 96
         if self.is_dns_compatible():
94
-            return "http://%s.%s/%s" % (self._bucket, Config.Config().host_base, self._object)
97
+            return "%s://%s.%s/%s" % (public_url_protocol, self._bucket, Config.Config().host_base, self._object)
95 98
         else:
96
-            return "http://%s/%s/%s" % (Config.Config().host_base, self._bucket, self._object)
99
+            return "%s://%s/%s/%s" % (public_url_protocol, Config.Config().host_base, self._bucket, self._object)
97 100
 
98 101
     def host_name(self):
99 102
         if self.is_dns_compatible():