summaryrefslogtreecommitdiff
path: root/django/middleware/common.py
diff options
context:
space:
mode:
authorUnai Zalakain <unai@gisa-elkartea.org>2013-10-08 20:30:29 +0200
committerTim Graham <timograham@gmail.com>2013-10-15 09:04:12 -0400
commitc7634cd7fe7dc09338fcec0ca48d816a29d791b0 (patch)
treee7e2d0d4c17dcaa6ed8eaf3f61741409ea988aae /django/middleware/common.py
parent9bfe66164e0e214abc6063a1a60ce729094d0632 (diff)
Fixed #7603 -- Added a 'scheme' property to the HttpRequest object
`HttpRequest.scheme` is `https` if `settings.SECURE_PROXY_SSL_HEADER` is appropriately set and falls back to `HttpRequest._get_scheme()` (a hook for subclasses to implement) otherwise. `WSGIRequest._get_scheme()` makes use of the `wsgi.url_scheme` WSGI environ variable to determine the request scheme. `HttpRequest.is_secure()` simply checks if `HttpRequest.scheme` is `https`. This provides a way to check the current scheme in templates, for example. It also allows us to deal with other schemes. Thanks nslater for the suggestion.
Diffstat (limited to 'django/middleware/common.py')
-rw-r--r--django/middleware/common.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 8f5923ac4a..51fcf1b2af 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -85,7 +85,7 @@ class CommonMiddleware(object):
return
if new_url[0]:
newurl = "%s://%s%s" % (
- 'https' if request.is_secure() else 'http',
+ request.scheme,
new_url[0], urlquote(new_url[1]))
else:
newurl = urlquote(new_url[1])