Fix response of Upload Part Copy requests

Fix root tag of response body for Upload Part Copy requests.
Correct body is following.

<?xml version="1.0" encoding="UTF-8"?>
<CopyPartResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <LastModified>2015-01-16T07:42:41.000Z</LastModified>
    <ETag>"dd0591c4f082a4b1b57ea779a1566a28"</ETag>
</CopyPartResult>

Change-Id: I69801c50670c576485a9f0f5c12e578c1c433374
This commit is contained in:
Naoto Nishizono 2015-01-16 16:57:51 +09:00
parent a0834c83a4
commit 1a0253638f
6 changed files with 23 additions and 5 deletions

View File

@ -0,0 +1,5 @@
start =
element CopyPartResult {
element LastModified { xsd:dateTime },
element ETag { xsd:string }
}

View File

@ -114,7 +114,7 @@ class PartController(Controller):
resp = req.get_response(self.app)
if 'X-Amz-Copy-Source' in req.headers:
resp.append_copy_resp_body()
resp.append_copy_resp_body(req.controller_name)
resp.status = 200
return resp

View File

@ -96,7 +96,7 @@ class ObjectController(Controller):
resp = req.get_response(self.app)
if 'X-Amz-Copy-Source' in req.headers:
resp.append_copy_resp_body()
resp.append_copy_resp_body(req.controller_name)
resp.status = HTTP_OK
return resp

View File

@ -135,8 +135,8 @@ class Response(ResponseBase, swob.Response):
return resp
def append_copy_resp_body(self):
elem = Element('CopyObjectResult')
def append_copy_resp_body(self, controller_name):
elem = Element('Copy%sResult' % controller_name)
SubElement(elem, 'LastModified').text = \
self.last_modified.isoformat()[:-6] + '.000Z'
SubElement(elem, 'ETag').text = '"%s"' % self.etag

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="CopyPartResult">
<element name="LastModified">
<data type="dateTime"/>
</element>
<element name="ETag">
<data type="string"/>
</element>
</element>
</start>
</grammar>

View File

@ -751,7 +751,7 @@ class TestSwift3MultiUpload(Swift3TestCase):
self.assertEquals(status.split()[0], '200')
self.assertEquals(headers['Content-Type'], 'application/xml')
self.assertTrue(headers.get('etag') is None)
elem = fromstring(body, 'CopyObjectResult')
elem = fromstring(body, 'CopyPartResult')
self.assertEquals(elem.find('LastModified').text, iso_format)
self.assertEquals(elem.find('ETag').text, '"%s"' % self.etag)