Fixed account and container listings so they return with charset=utf-8 instead of utf8.
This commit is contained in:
commit
04b0e82422
@ -244,7 +244,7 @@ class AccountController(object):
|
||||
account_list = '\n'.join(r[0] for r in account_list) + '\n'
|
||||
ret = Response(body=account_list, request=req, headers=resp_headers)
|
||||
ret.content_type = out_content_type
|
||||
ret.charset = 'utf8'
|
||||
ret.charset = 'utf-8'
|
||||
return ret
|
||||
|
||||
def REPLICATE(self, req):
|
||||
|
@ -334,7 +334,7 @@ class ContainerController(object):
|
||||
container_list = '\n'.join(r[0] for r in container_list) + '\n'
|
||||
ret = Response(body=container_list, request=req, headers=resp_headers)
|
||||
ret.content_type = out_content_type
|
||||
ret.charset = 'utf8'
|
||||
ret.charset = 'utf-8'
|
||||
return ret
|
||||
|
||||
def REPLICATE(self, req):
|
||||
|
@ -227,10 +227,10 @@ class TestAccount(Base):
|
||||
headers = dict(self.env.conn.response.getheaders())
|
||||
if format == 'json':
|
||||
self.assertEquals(headers['content-type'],
|
||||
'application/json; charset=utf8')
|
||||
'application/json; charset=utf-8')
|
||||
elif format == 'xml':
|
||||
self.assertEquals(headers['content-type'],
|
||||
'application/xml; charset=utf8')
|
||||
'application/xml; charset=utf-8')
|
||||
|
||||
def testListingLimit(self):
|
||||
limit = 10000
|
||||
@ -1355,10 +1355,10 @@ class TestFile(Base):
|
||||
headers = dict(self.env.conn.response.getheaders())
|
||||
if format == 'json':
|
||||
self.assertEquals(headers['content-type'],
|
||||
'application/json; charset=utf8')
|
||||
'application/json; charset=utf-8')
|
||||
elif format == 'xml':
|
||||
self.assertEquals(headers['content-type'],
|
||||
'application/xml; charset=utf8')
|
||||
'application/xml; charset=utf-8')
|
||||
|
||||
lm_diff = max([f['last_modified'] for f in files]) - \
|
||||
min([f['last_modified'] for f in files])
|
||||
|
@ -388,6 +388,7 @@ class TestAccountController(unittest.TestCase):
|
||||
self.assertEquals(resp.status_int, 200)
|
||||
self.assertEquals(resp.body.strip().split('\n'), ['c1', 'c2'])
|
||||
self.assertEquals(resp.content_type, 'text/plain')
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
def test_GET_with_containers_json(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -436,6 +437,7 @@ class TestAccountController(unittest.TestCase):
|
||||
[{'count': 1, 'bytes': 2, 'name': 'c1'},
|
||||
{'count': 3, 'bytes': 4, 'name': 'c2'}])
|
||||
self.assertEquals(resp.content_type, 'application/json')
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
def test_GET_with_containers_xml(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -529,6 +531,7 @@ class TestAccountController(unittest.TestCase):
|
||||
self.assertEquals(node.firstChild.nodeValue, '3')
|
||||
node = [n for n in container if n.nodeName == 'bytes'][0]
|
||||
self.assertEquals(node.firstChild.nodeValue, '4')
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
def test_GET_limit_marker_plain(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
|
@ -187,7 +187,7 @@ class FakeApp(object):
|
||||
headers.update({'X-Container-Object-Count': '11',
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'X-Container-Read': '.r:*',
|
||||
'Content-Type': 'application/json; charset=utf8'})
|
||||
'Content-Type': 'application/json; charset=utf-8'})
|
||||
body = '''
|
||||
[{"name":"subdir/1.txt",
|
||||
"hash":"5f595114a4b3077edfac792c61ca4fe4", "bytes":20,
|
||||
@ -204,14 +204,14 @@ class FakeApp(object):
|
||||
headers.update({'X-Container-Object-Count': '11',
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'X-Container-Read': '.r:*',
|
||||
'Content-Type': 'application/json; charset=utf8'})
|
||||
'Content-Type': 'application/json; charset=utf-8'})
|
||||
body = '[]'
|
||||
elif env['PATH_INFO'] == '/v1/a/c3' and env['QUERY_STRING'] == \
|
||||
'limit=1&format=json&delimiter=/&limit=1&prefix=subdirz/':
|
||||
headers.update({'X-Container-Object-Count': '11',
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'X-Container-Read': '.r:*',
|
||||
'Content-Type': 'application/json; charset=utf8'})
|
||||
'Content-Type': 'application/json; charset=utf-8'})
|
||||
body = '''
|
||||
[{"name":"subdirz/1.txt",
|
||||
"hash":"5f595114a4b3077edfac792c61ca4fe4", "bytes":20,
|
||||
@ -224,7 +224,7 @@ class FakeApp(object):
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'X-Container-Read': '.r:*',
|
||||
'X-Container-Web-Listings': 't',
|
||||
'Content-Type': 'application/json; charset=utf8'})
|
||||
'Content-Type': 'application/json; charset=utf-8'})
|
||||
body = '''
|
||||
[{"name":"subdir/1.txt",
|
||||
"hash":"5f595114a4b3077edfac792c61ca4fe4", "bytes":20,
|
||||
@ -236,7 +236,7 @@ class FakeApp(object):
|
||||
elif 'format=json' in env['QUERY_STRING']:
|
||||
headers.update({'X-Container-Object-Count': '11',
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'Content-Type': 'application/json; charset=utf8'})
|
||||
'Content-Type': 'application/json; charset=utf-8'})
|
||||
body = '''
|
||||
[{"name":"401error.html",
|
||||
"hash":"893f8d80692a4d3875b45be8f152ad18", "bytes":110,
|
||||
@ -283,7 +283,7 @@ class FakeApp(object):
|
||||
else:
|
||||
headers.update({'X-Container-Object-Count': '11',
|
||||
'X-Container-Bytes-Used': '73741',
|
||||
'Content-Type': 'text/plain; charset=utf8'})
|
||||
'Content-Type': 'text/plain; charset=utf-8'})
|
||||
body = '\n'.join(['401error.html', '404error.html', 'index.html',
|
||||
'listing.css', 'one.txt', 'subdir/1.txt',
|
||||
'subdir/2.txt', 'subdir/omgomg.txt', 'subdir2',
|
||||
|
@ -514,6 +514,7 @@ class TestContainerController(unittest.TestCase):
|
||||
resp = self.controller.GET(req)
|
||||
self.assertEquals(resp.content_type, 'application/json')
|
||||
self.assertEquals(eval(resp.body), json_body)
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
for accept in ('application/json', 'application/json;q=1.0,*/*;q=0.9',
|
||||
'*/*;q=0.9,application/json;q=1.0', 'application/*'):
|
||||
@ -552,6 +553,7 @@ class TestContainerController(unittest.TestCase):
|
||||
resp = self.controller.GET(req)
|
||||
self.assertEquals(resp.content_type, 'text/plain')
|
||||
self.assertEquals(resp.body, plain_body)
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
for accept in ('', 'text/plain', 'application/xml;q=0.8,*/*;q=0.9',
|
||||
'*/*;q=0.9,application/xml;q=0.8', '*/*',
|
||||
@ -609,6 +611,7 @@ class TestContainerController(unittest.TestCase):
|
||||
resp = self.controller.GET(req)
|
||||
self.assertEquals(resp.content_type, 'application/xml')
|
||||
self.assertEquals(resp.body, xml_body)
|
||||
self.assertEquals(resp.charset, 'utf-8')
|
||||
|
||||
for xml_accept in ('application/xml', 'application/xml;q=1.0,*/*;q=0.9',
|
||||
'*/*;q=0.9,application/xml;q=1.0', 'application/xml,text/xml'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user