Skip to content

Commit 7196a32

Browse files
committed
fix for listing_iter
Change-Id: I2a32d333af7ed87208928032d6f6c44e78ee6dee
1 parent 4b3f96d commit 7196a32

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

swift/proxy/server.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -868,25 +868,28 @@ def _listing_iter(self, lcontainer, lprefix, env):
868868
self.account_name, lcontainer)
869869
marker = ''
870870
while True:
871-
path = '/%s/%s' % (quote(self.account_name), quote(lcontainer))
872-
lreq = Request.blank(
873-
'%s?prefix=%s&format=json&marker=%s' %
874-
(path, quote(lprefix), quote(marker)), environ=env)
871+
lreq = Request.blank('i will be overridden by env', environ=env)
872+
lreq.environ['PATH_INFO'] = \
873+
'/%s/%s' % (quote(self.account_name), quote(lcontainer))
875874
lreq.environ['REQUEST_METHOD'] = 'GET'
876-
lreq.path_info = path
875+
lreq.environ['QUERY_STRING'] = \
876+
'format=json&prefix=%s&marker=%s' % (quote(lprefix),
877+
quote(marker))
877878
shuffle(lnodes)
878879
lresp = self.GETorHEAD_base(lreq, _('Container'),
879880
lpartition, lnodes, lreq.path_info,
880881
self.app.container_ring.replica_count)
881-
if lresp.status_int == 404:
882-
raise ListingIterNotFound()
883-
elif lresp.status_int // 100 != 2:
884-
raise ListingIterError()
885882
if 'swift.authorize' in env:
886883
lreq.acl = lresp.headers.get('x-container-read')
887884
aresp = env['swift.authorize'](lreq)
888885
if aresp:
889886
raise ListingIterNotAuthorized(aresp)
887+
if lresp.status_int == 404:
888+
raise ListingIterNotFound()
889+
elif lresp.status_int // 100 != 2:
890+
raise ListingIterError()
891+
if not lresp.body:
892+
break
890893
sublisting = json.loads(lresp.body)
891894
if not sublisting:
892895
break

0 commit comments

Comments
 (0)