summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPREMANAND <prem1pre@gmail.com>2016-11-17 12:46:42 -0500
committerTim Graham <timograham@gmail.com>2016-11-17 12:46:42 -0500
commit371adc472a2a1f09923101e3c4fda60cdff96028 (patch)
tree6f73f36f03d0a7fba324958b399889fbd5188137
parentb28c6ca7631e13ea29490bf51a367ab10198c74c (diff)
Fixed #27156 -- Made changing HttpRequest.encoding clear GET.
-rw-r--r--django/http/request.py4
-rw-r--r--tests/requests/tests.py10
2 files changed, 12 insertions, 2 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 73858c5abd..83131d52c3 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -226,8 +226,8 @@ class HttpRequest(object):
next access (so that it is decoded correctly).
"""
self._encoding = val
- if hasattr(self, '_get'):
- del self._get
+ if hasattr(self, 'GET'):
+ del self.GET
if hasattr(self, '_post'):
del self._post
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index 4989071cbb..1a243a02b0 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -562,6 +562,16 @@ class RequestsTests(SimpleTestCase):
request.encoding = 'iso-8859-16'
self.assertEqual(request.POST, {'name': ['Hello GĂŒnter']})
+ def test_set_encoding_clears_GET(self):
+ request = WSGIRequest({
+ 'REQUEST_METHOD': 'GET',
+ 'wsgi.input': '',
+ 'QUERY_STRING': b'name=Hello%20G%C3%BCnter' if six.PY2 else 'name=Hello%20G%C3%BCnter'
+ })
+ self.assertEqual(request.GET, {'name': ['Hello Günter']})
+ request.encoding = 'iso-8859-16'
+ self.assertEqual(request.GET, {'name': ['Hello G\u0102\u0152nter']})
+
def test_FILES_connection_error(self):
"""
If wsgi.input.read() raises an exception while trying to read() the