David Larlet avatar David Larlet committed 5790493

Fixes #105, add an optional setting to the boto storage to produce protocol-relative URLs, thanks @idangazit @pendletongp and @derrickpetzold

Comments (2)

  1. anttihirvonen

    It seems so – I just tried to enable schemaless urls without custom domain and they didn't work. Is there any particular reason why custom domain is required?

Files changed (1)


+URL_PROTOCOL = getattr(settings, 'AWS_S3_URL_PROTOCOL', 'http:')
+# Backward-compatibility: given the anteriority of the SECURE_URL setting
+# we fall back to https if specified in order to avoid the construction
+# of unsecure urls.
+    URL_PROTOCOL = 'https:'
     from gzip import GzipFile
+            url_protocol=URL_PROTOCOL,
         self.encryption = encryption
         self.custom_domain = custom_domain
         self.secure_urls = secure_urls
+        self.url_protocol = url_protocol
         self.location = location or ''
         self.location = self.location.lstrip('/')
         self.file_name_charset = file_name_charset
     def url(self, name):
         name = self._normalize_name(self._clean_name(name))
         if self.custom_domain:
-            return "%s://%s/%s" % ('https' if self.secure_urls else 'http',
-                                   self.custom_domain, name)
+            return "%s//%s/%s" % (self.url_protocol,
+                                  self.custom_domain, name)
         return self.connection.generate_url(self.querystring_expire,
             method='GET', bucket=self.bucket.name, key=self._encode_name(name),
             query_auth=self.querystring_auth, force_http=not self.secure_urls)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.