mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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.
This commit is contained in:
committed by
Tim Graham
parent
9bfe66164e
commit
c7634cd7fe
@@ -51,8 +51,8 @@ class LocaleMiddleware(object):
|
||||
|
||||
if path_valid:
|
||||
language_url = "%s://%s/%s%s" % (
|
||||
'https' if request.is_secure() else 'http',
|
||||
request.get_host(), language, request.get_full_path())
|
||||
request.scheme, request.get_host(), language,
|
||||
request.get_full_path())
|
||||
return self.response_redirect_class(language_url)
|
||||
|
||||
# Store language back into session if it is not present
|
||||
|
||||
Reference in New Issue
Block a user