charset for default responses
Set a utf-8 charset on default text/html responses. Change-Id: Ic5f661bd475dca83763d4b55419ad031279e3ba1
This commit is contained in:
parent
0ab0c813c0
commit
65554ea32f
|
@ -944,14 +944,14 @@ class Response(object):
|
|||
_body_slicer)
|
||||
if app_iter:
|
||||
return app_iter
|
||||
if body:
|
||||
if body is not None:
|
||||
return [body]
|
||||
if self.status_int in RESPONSE_REASONS:
|
||||
title, exp = RESPONSE_REASONS[self.status_int]
|
||||
self.content_type = 'text/html; charset=UTF-8'
|
||||
if exp:
|
||||
body = '<html><h1>%s</h1><p>%s</p></html>' % (title, exp)
|
||||
self.content_length = len(body)
|
||||
self.content_type = 'text/html'
|
||||
return [body]
|
||||
return ['']
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ class TestStatusMap(unittest.TestCase):
|
|||
self.assert_('The resource could not be found.' in body)
|
||||
self.assertEquals(response_args[0], '404 Not Found')
|
||||
headers = dict(response_args[1])
|
||||
self.assertEquals(headers['content-type'], 'text/html')
|
||||
self.assertEquals(headers['content-type'], 'text/html; charset=UTF-8')
|
||||
self.assert_(int(headers['content-length']) > 0)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue