Merge "Accept URL-encoded x-amz-copy-source headers"
This commit is contained in:
commit
77cc55b41f
|
@ -15,7 +15,7 @@
|
|||
|
||||
import re
|
||||
import md5
|
||||
from urllib import quote
|
||||
from urllib import quote, unquote
|
||||
import base64
|
||||
import email.utils
|
||||
import datetime
|
||||
|
@ -325,7 +325,7 @@ class Request(swob.Request):
|
|||
check_copy_source checks the copy source existence
|
||||
"""
|
||||
if 'X-Amz-Copy-Source' in self.headers:
|
||||
src_path = self.headers['X-Amz-Copy-Source']
|
||||
src_path = unquote(self.headers['X-Amz-Copy-Source'])
|
||||
src_path = src_path if src_path.startswith('/') else \
|
||||
('/' + src_path)
|
||||
src_bucket, src_obj = split_path(src_path, 0, 2, True)
|
||||
|
|
|
@ -21,6 +21,7 @@ from time import mktime
|
|||
from multifile import MultiFile
|
||||
from cStringIO import StringIO
|
||||
from hashlib import md5
|
||||
from urllib import quote
|
||||
|
||||
from swift3.test.functional.s3_test_client import Connection
|
||||
from swift3.test.functional.utils import get_error_code,\
|
||||
|
@ -43,7 +44,7 @@ class TestSwift3Object(Swift3FunctionalTestCase):
|
|||
self.assertCommonResponseHeaders(headers, etag)
|
||||
|
||||
def test_object(self):
|
||||
obj = 'object'
|
||||
obj = 'object name with %-sign'
|
||||
content = 'abc123'
|
||||
etag = md5(content).hexdigest()
|
||||
|
||||
|
@ -67,6 +68,16 @@ class TestSwift3Object(Swift3FunctionalTestCase):
|
|||
headers=headers)
|
||||
self.assertEquals(status, 200)
|
||||
|
||||
# PUT Object Copy with URL-encoded Source
|
||||
dst_bucket = 'dst-bucket'
|
||||
dst_obj = 'dst_obj'
|
||||
self.conn.make_request('PUT', dst_bucket)
|
||||
headers = {'x-amz-copy-source': quote('/%s/%s' % (self.bucket, obj))}
|
||||
status, headers, body = \
|
||||
self.conn.make_request('PUT', dst_bucket, dst_obj,
|
||||
headers=headers)
|
||||
self.assertEquals(status, 200)
|
||||
|
||||
self.assertCommonResponseHeaders(headers)
|
||||
self.assertEquals(headers['content-length'], str(len(body)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue