Fixed #13140 -- Ensure that request headers are preserved through redirect chains in the test client. Thanks to David Novakovic for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13620 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-08-21 03:01:46 +00:00
parent 8cd5d28369
commit 26b3fb1e82
4 changed files with 28 additions and 8 deletions

View file

@ -847,3 +847,17 @@ class UploadedFileEncodingTest(TestCase):
encode_file('IGNORE', 'IGNORE', DummyFile("file.zip"))[2])
self.assertEqual('Content-Type: application/octet-stream',
encode_file('IGNORE', 'IGNORE', DummyFile("file.unknown"))[2])
class RequestHeadersTest(TestCase):
def test_client_headers(self):
"A test client can receive custom headers"
response = self.client.get("/test_client_regress/check_headers/", HTTP_X_ARG_CHECK='Testing 123')
self.assertEquals(response.content, "HTTP_X_ARG_CHECK: Testing 123")
self.assertEquals(response.status_code, 200)
def test_client_headers_redirect(self):
"Test client headers are preserved through redirects"
response = self.client.get("/test_client_regress/check_headers_redirect/", follow=True, HTTP_X_ARG_CHECK='Testing 123')
self.assertEquals(response.content, "HTTP_X_ARG_CHECK: Testing 123")
self.assertRedirects(response, '/test_client_regress/check_headers/',
status_code=301, target_status_code=200)