summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/handlers/wsgi.py29
1 files changed, 10 insertions, 19 deletions
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 21cadf48b8..46efd0477e 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -14,6 +14,7 @@ from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
from django.utils.encoding import force_str, force_text
+from django.utils.functional import cached_property
from django.utils import six
# For backwards compatibility -- lots of code uses this in the wild!
@@ -136,15 +137,11 @@ class WSGIRequest(http.HttpRequest):
self._request = datastructures.MergeDict(self.POST, self.GET)
return self._request
- def _get_get(self):
- if not hasattr(self, '_get'):
- # The WSGI spec says 'QUERY_STRING' may be absent.
- raw_query_string = get_bytes_from_wsgi(self.environ, 'QUERY_STRING', '')
- self._get = http.QueryDict(raw_query_string, encoding=self._encoding)
- return self._get
-
- def _set_get(self, get):
- self._get = get
+ @cached_property
+ def GET(self):
+ # The WSGI spec says 'QUERY_STRING' may be absent.
+ raw_query_string = get_bytes_from_wsgi(self.environ, 'QUERY_STRING', '')
+ return http.QueryDict(raw_query_string, encoding=self._encoding)
def _get_post(self):
if not hasattr(self, '_post'):
@@ -154,23 +151,17 @@ class WSGIRequest(http.HttpRequest):
def _set_post(self, post):
self._post = post
- def _get_cookies(self):
- if not hasattr(self, '_cookies'):
- raw_cookie = get_str_from_wsgi(self.environ, 'HTTP_COOKIE', '')
- self._cookies = http.parse_cookie(raw_cookie)
- return self._cookies
-
- def _set_cookies(self, cookies):
- self._cookies = cookies
+ @cached_property
+ def COOKIES(self):
+ raw_cookie = get_str_from_wsgi(self.environ, 'HTTP_COOKIE', '')
+ return http.parse_cookie(raw_cookie)
def _get_files(self):
if not hasattr(self, '_files'):
self._load_post_and_files()
return self._files
- GET = property(_get_get, _set_get)
POST = property(_get_post, _set_post)
- COOKIES = property(_get_cookies, _set_cookies)
FILES = property(_get_files)
REQUEST = property(_get_request)