Exemple #1
0
 def test_alternate_charset_POST(self):
     """
     Test a POST with non-utf-8 payload encoding.
     """
     from django.utils.http import urllib_parse
     payload = FakePayload(urllib_parse.urlencode({'key': 'España'.encode('latin-1')}))
     request = WSGIRequest({
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': len(payload),
         'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=iso-8859-1',
         'wsgi.input': payload,
     })
     self.assertEqual(request.POST, {'key': ['España']})
Exemple #2
0
 def test_alternate_charset_POST(self):
     """
     Test a POST with non-utf-8 payload encoding.
     """
     from django.utils.http import urllib_parse
     payload = FakePayload(urllib_parse.urlencode({'key': 'España'.encode('latin-1')}))
     request = WSGIRequest({
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': len(payload),
         'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=iso-8859-1',
         'wsgi.input': payload,
     })
     self.assertEqual(request.POST, {'key': ['España']})
Exemple #3
0
    def test_alternate_charset_POST(self):
        """
        Test a POST with non-utf-8 payload encoding.
        """
        from django.utils.http import urllib_parse

        payload = FakePayload(urllib_parse.urlencode({"key": "España".encode("latin-1")}))
        request = WSGIRequest(
            {
                "REQUEST_METHOD": "POST",
                "CONTENT_LENGTH": len(payload),
                "CONTENT_TYPE": "application/x-www-form-urlencoded; charset=iso-8859-1",
                "wsgi.input": payload,
            }
        )
        self.assertEqual(request.POST, {"key": ["España"]})