Don't redirect dynamic CSS from https to http

This can break things (d'uh).

Do this by introducing a new decorator, @ssl_optional. When this is
present, no SSL redirection will happen, regardless of whether the
access comes in over http or https.

This decorator overrides @ssl_required, but for redability's sake,
never use both at the same time.
This commit is contained in:
Magnus Hagander
2014-01-02 12:00:32 +01:00
parent 137d4295f3
commit 048a17ae4b
3 changed files with 14 additions and 1 deletions

View File

@ -8,6 +8,13 @@ def ssl_required(fn):
# wraps retains original function attributes such as __name__, csrf_exempt, etc
return wraps(_require_ssl)(fn)
def ssl_optional(fn):
def _optional_ssl(request, *_args, **_kwargs):
return fn(request, *_args, **_kwargs)
_optional_ssl.ssl_optional = True
# wraps retains original function attributes such as __name__, csrf_exempt, etc
return wraps(_optional_ssl)(fn)
def nocache(fn):
def _nocache(request, *_args, **_kwargs):
resp = fn(request, *_args, **_kwargs)