Skip to content

Commit cd0a62c

Browse files
committed
slo: Fix MPU with reserved characters
1 parent 71ab57a commit cd0a62c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

oioswift/common/middleware/slo.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from hashlib import md5
2626
import mimetypes
2727
import six
28+
from six.moves.urllib.parse import urlencode
2829
import time
2930

3031
from oio.common.json import json
@@ -447,11 +448,14 @@ def resp_iter(total_size=total_size):
447448
last_yield_time = time.time()
448449

449450
# BEGIN: New OpenIO code
451+
params = {
452+
'format': 'json',
453+
'prefix': seg_prefix,
454+
'limit': self.max_manifest_segments
455+
}
450456
sub_req = make_subrequest(
451457
req.environ,
452-
path='%s?format=json&prefix=%s&limit=%d' %
453-
(segments_container_path, seg_prefix,
454-
self.max_manifest_segments),
458+
path='%s?%s' % (segments_container_path, urlencode(params)),
455459
method='GET',
456460
headers={'x-auth-token': req.headers.get('x-auth-token')},
457461
agent='%(orig)s SLO MultipartPUT', swift_source='SLO')

tests/functional/s3-mpu.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
import os
1010

11-
ENDPOINT = os.getenv("USE_ENDPOINT", "http://127.0.0.1:5000")
11+
ENDPOINT = os.getenv("USE_ENDPOINT", "http://localhost:5000")
1212
AWS = ["aws", "--endpoint", ENDPOINT]
1313

1414
random_chars = string.lowercase + string.digits
@@ -142,9 +142,19 @@ def run_test(bucket, path):
142142

143143
def main():
144144
run_test(random_str(10),
145-
"docker/registry/v2/repositories/hello/_uploads/333633b0-503f-4b2a-9b43-e56ec6445ef3/data") # noqa
145+
"docker/registry/v2/repositories/hello/_uploads/"
146+
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data")
147+
run_test(random_str(10),
148+
"docker/registry/v2/repositories/hello+world/_uploads/"
149+
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data")
150+
run_test(random_str(10),
151+
"docker/registry/v2/repositories/hello/_uploads/"
152+
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data+")
146153
run_test(random_str(10),
147154
"CBB_DESKTOP-1LC5CCV/C:/Bombay/Logs/titi:/12121212/titi")
155+
run_test(random_str(10),
156+
"CBB_DESKTOP-1LC5CCV/C:/Bombay/Logs/titi+rominet:/12121212/"
157+
"titi+rominet")
148158
run_test(random_str(10), random_str(10))
149159

150160

0 commit comments

Comments
 (0)