Always use same URL for both secure and non-secure CDN requests

Use a scheme-relative URL rather than serving different content to
users based on HTTP or HTTPS. Should prevent mismatched certificate
errors.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-11-08 13:55:38 -06:00
parent 28f72db7be
commit 886630dd4e
2 changed files with 3 additions and 9 deletions

View File

@ -53,8 +53,7 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000'
## CDN settings
CDN_ENABLED = False
CDN_PATH = 'http://example.com/path/'
CDN_PATH_SECURE = 'https://example.com/path/'
# Scheme-relative URL, should work for both http/https
CDN_PATH = '//example.com/path/'
# vim: set ts=4 sw=4 et:

View File

@ -23,12 +23,7 @@ def render(self, context):
oncdn = getattr(settings, 'CDN_ENABLED', True)
if not oncdn:
return ''
secure = 'secure' in context and context['secure']
# if left undefined, same behavior as if CDN is turned off
paths = {
False: getattr(settings, 'CDN_PATH', ''),
True: getattr(settings, 'CDN_PATH_SECURE', ''),
}
return paths[secure]
return getattr(settings, 'CDN_PATH', '')
# vim: set ts=4 sw=4 et: