summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/test/client.py2
-rw-r--r--docs/releases/2.2.txt3
-rw-r--r--tests/test_client/tests.py2
3 files changed, 5 insertions, 2 deletions
diff --git a/django/test/client.py b/django/test/client.py
index 776410cefa..d961c2c282 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -401,7 +401,7 @@ class RequestFactory:
}
if data:
r.update({
- 'CONTENT_LENGTH': len(data),
+ 'CONTENT_LENGTH': str(len(data)),
'CONTENT_TYPE': content_type,
'wsgi.input': FakePayload(data),
})
diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt
index 86d9ee46c0..dffb5bd12b 100644
--- a/docs/releases/2.2.txt
+++ b/docs/releases/2.2.txt
@@ -228,6 +228,9 @@ Miscellaneous
have existing invalid data and run a migration that recreates a table, you'll
see ``CHECK constraint failed``.
+* For consistency with WSGI servers, the test client now sets the
+ ``Content-Length`` header to a string rather than an integer.
+
.. _deprecated-features-2.2:
Features deprecated in 2.2
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index e45a743f22..b39d5f5e09 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -122,7 +122,7 @@ class ClientTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.templates[0].name, 'PUT Template')
self.assertEqual(response.context['data'], "{'foo': 'bar'}")
- self.assertEqual(response.context['Content-Length'], 14)
+ self.assertEqual(response.context['Content-Length'], '14')
def test_trace(self):
"""TRACE a view"""