Skip to content

Commit

Permalink
Ensure we only send a single content-type header
Browse files Browse the repository at this point in the history
Fixes bug 917438

Change-Id: Ic71bd139f77ed7f291eca258c123deb30c7177ce
  • Loading branch information
Brian Waldon authored and bcwaldon committed Jan 19, 2012
1 parent e893b24 commit b712949
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion glance/common/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def sanitizer(obj):
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)


Expand Down
3 changes: 3 additions & 0 deletions glance/tests/unit/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def test_default(self):
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"}')

Expand Down

0 comments on commit b712949

Please sign in to comment.