mirror of
https://github.com/sprockets/sprockets.mixins.mediatype.git
synced 2024-12-29 11:17:10 +00:00
default to the set content type default in settings
This commit is contained in:
parent
ebf8fe4f6f
commit
212dcb7876
2 changed files with 11 additions and 1 deletions
|
@ -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)
|
||||
|
|
7
tests.py
7
tests.py
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in a new issue