default to the set content type default in settings

This commit is contained in:
Amber Heilman 2015-09-14 11:13:07 -04:00
parent ebf8fe4f6f
commit 212dcb7876
2 changed files with 11 additions and 1 deletions

View file

@ -178,7 +178,10 @@ class ContentMixin(object):
if self._best_response_match is None:
settings = ContentSettings.from_application(self.application)
acceptable = headers.parse_http_accept_header(
self.request.headers.get('Accept', '*/*'))
self.request.headers.get(
'Accept',
settings.default_content_type
if settings.default_content_type else '*/*'))
try:
selected, _ = algorithms.select_content_type(
acceptable, settings.available_content_types)

View file

@ -34,6 +34,13 @@ class SendResponseTests(testing.AsyncHTTPTestCase):
self.assertEqual(response.headers['Content-Type'],
'application/msgpack')
def test_that_default_content_type_is_set_on_response(self):
response = self.fetch('/', method='POST', body=msgpack.packb('{}'),
headers={'Content-Type': 'application/msgpack'})
self.assertEqual(response.code, 200)
self.assertEqual(response.headers['Content-Type'],
'application/json; charset="utf-8"')
class GetRequestBodyTests(testing.AsyncHTTPTestCase):