Skip to content

Commit

Permalink
slo: Fix MPU with reserved characters
Browse files Browse the repository at this point in the history
  • Loading branch information
AymericDu committed Feb 7, 2022
1 parent 71ab57a commit cd0a62c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 7 additions & 3 deletions oioswift/common/middleware/slo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from hashlib import md5
import mimetypes
import six
from six.moves.urllib.parse import urlencode
import time

from oio.common.json import json
Expand Down Expand Up @@ -447,11 +448,14 @@ def resp_iter(total_size=total_size):
last_yield_time = time.time()

# BEGIN: New OpenIO code
params = {
'format': 'json',
'prefix': seg_prefix,
'limit': self.max_manifest_segments
}
sub_req = make_subrequest(
req.environ,
path='%s?format=json&prefix=%s&limit=%d' %
(segments_container_path, seg_prefix,
self.max_manifest_segments),
path='%s?%s' % (segments_container_path, urlencode(params)),
method='GET',
headers={'x-auth-token': req.headers.get('x-auth-token')},
agent='%(orig)s SLO MultipartPUT', swift_source='SLO')
Expand Down
14 changes: 12 additions & 2 deletions tests/functional/s3-mpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import json
import os

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

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

def main():
run_test(random_str(10),
"docker/registry/v2/repositories/hello/_uploads/333633b0-503f-4b2a-9b43-e56ec6445ef3/data") # noqa
"docker/registry/v2/repositories/hello/_uploads/"
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data")
run_test(random_str(10),
"docker/registry/v2/repositories/hello+world/_uploads/"
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data")
run_test(random_str(10),
"docker/registry/v2/repositories/hello/_uploads/"
"333633b0-503f-4b2a-9b43-e56ec6445ef3/data+")
run_test(random_str(10),
"CBB_DESKTOP-1LC5CCV/C:/Bombay/Logs/titi:/12121212/titi")
run_test(random_str(10),
"CBB_DESKTOP-1LC5CCV/C:/Bombay/Logs/titi+rominet:/12121212/"
"titi+rominet")
run_test(random_str(10), random_str(10))


Expand Down

0 comments on commit cd0a62c

Please sign in to comment.