Ensure we only send a single content-type header

Fixes bug 917438

Change-Id: Ic71bd139f77ed7f291eca258c123deb30c7177ce
This commit is contained in:
Brian Waldon 2012-01-19 11:15:36 -08:00 committed by Brian Waldon
parent e893b248a2
commit b712949ec5
2 changed files with 4 additions and 1 deletions

View File

@ -430,7 +430,7 @@ class JSONResponseSerializer(object):
return json.dumps(data, default=sanitizer)
def default(self, response, result):
response.headers.add('Content-Type', 'application/json')
response.content_type = 'application/json'
response.body = self.to_json(result)

View File

@ -134,6 +134,9 @@ class JSONResponseSerializerTest(unittest.TestCase):
response = webob.Response()
wsgi.JSONResponseSerializer().default(response, fixture)
self.assertEqual(response.status_int, 200)
content_types = filter(lambda h: h[0] == 'Content-Type',
response.headerlist)
self.assertEqual(len(content_types), 1)
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.body, '{"key": "value"}')