Merge "fix large objects with unicode"
This commit is contained in:
commit
ce49777892
@ -57,6 +57,15 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPNotFound, \
|
||||
HTTPClientDisconnect
|
||||
|
||||
|
||||
def segment_listing_iter(listing):
|
||||
listing = iter(listing)
|
||||
while True:
|
||||
seg_dict = listing.next()
|
||||
if isinstance(seg_dict['name'], unicode):
|
||||
seg_dict['name'] = seg_dict['name'].encode('utf-8')
|
||||
yield seg_dict
|
||||
|
||||
|
||||
class SegmentedIterable(object):
|
||||
"""
|
||||
Iterable that returns the object contents for a segmented object in Swift.
|
||||
@ -77,7 +86,7 @@ class SegmentedIterable(object):
|
||||
def __init__(self, controller, container, listing, response=None):
|
||||
self.controller = controller
|
||||
self.container = container
|
||||
self.listing = iter(listing)
|
||||
self.listing = segment_listing_iter(listing)
|
||||
self.segment = 0
|
||||
self.segment_dict = None
|
||||
self.segment_peek = None
|
||||
@ -280,7 +289,7 @@ class ObjectController(Controller):
|
||||
sublisting = json.loads(lresp.body)
|
||||
if not sublisting:
|
||||
break
|
||||
marker = sublisting[-1]['name']
|
||||
marker = sublisting[-1]['name'].encode('utf-8')
|
||||
yield sublisting
|
||||
|
||||
def _remaining_items(self, listing_iter):
|
||||
|
@ -963,7 +963,7 @@ class TestObjectController(unittest.TestCase):
|
||||
listing3 = [{"hash": "6605f80e3cefaa24e9823544df4edbd6",
|
||||
"last_modified": "2012-11-08T04:05:37.853710",
|
||||
"bytes": 2,
|
||||
"name": "seg05",
|
||||
"name": u'\N{SNOWMAN}seg05',
|
||||
"content_type": "application/octet-stream"}]
|
||||
|
||||
response_bodies = (
|
||||
@ -1029,9 +1029,10 @@ class TestObjectController(unittest.TestCase):
|
||||
['GET', '/a/segments/seg04', {}],
|
||||
['GET', '/a/segments',
|
||||
{'format': 'json', 'prefix': 'seg', 'marker': 'seg04'}],
|
||||
['GET', '/a/segments/seg05', {}],
|
||||
['GET', '/a/segments/\xe2\x98\x83seg05', {}],
|
||||
['GET', '/a/segments',
|
||||
{'format': 'json', 'prefix': 'seg', 'marker': 'seg05'}]])
|
||||
{'format': 'json', 'prefix': 'seg',
|
||||
'marker': '\xe2\x98\x83seg05'}]])
|
||||
|
||||
finally:
|
||||
# other tests in this file get very unhappy if this
|
||||
|
Loading…
x
Reference in New Issue
Block a user