From 1a0253638f4097771f26f28e9cd92e2a513242cf Mon Sep 17 00:00:00 2001 From: Naoto Nishizono Date: Fri, 16 Jan 2015 16:57:51 +0900 Subject: [PATCH] Fix response of Upload Part Copy requests Fix root tag of response body for Upload Part Copy requests. Correct body is following. 2015-01-16T07:42:41.000Z "dd0591c4f082a4b1b57ea779a1566a28" Change-Id: I69801c50670c576485a9f0f5c12e578c1c433374 --- doc/rnc/copy_part_result.rnc | 5 +++++ swift3/controllers/multi_upload.py | 2 +- swift3/controllers/obj.py | 2 +- swift3/response.py | 4 ++-- swift3/schema/copy_part_result.rng | 13 +++++++++++++ swift3/test/unit/test_multi_upload.py | 2 +- 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 doc/rnc/copy_part_result.rnc create mode 100644 swift3/schema/copy_part_result.rng diff --git a/doc/rnc/copy_part_result.rnc b/doc/rnc/copy_part_result.rnc new file mode 100644 index 00000000..a7d79565 --- /dev/null +++ b/doc/rnc/copy_part_result.rnc @@ -0,0 +1,5 @@ +start = + element CopyPartResult { + element LastModified { xsd:dateTime }, + element ETag { xsd:string } + } diff --git a/swift3/controllers/multi_upload.py b/swift3/controllers/multi_upload.py index 0c40490d..e65821f6 100644 --- a/swift3/controllers/multi_upload.py +++ b/swift3/controllers/multi_upload.py @@ -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 diff --git a/swift3/controllers/obj.py b/swift3/controllers/obj.py index 817405f9..08e6a7d4 100644 --- a/swift3/controllers/obj.py +++ b/swift3/controllers/obj.py @@ -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 diff --git a/swift3/response.py b/swift3/response.py index 0ec38e07..db2dfd36 100644 --- a/swift3/response.py +++ b/swift3/response.py @@ -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 diff --git a/swift3/schema/copy_part_result.rng b/swift3/schema/copy_part_result.rng new file mode 100644 index 00000000..0370daad --- /dev/null +++ b/swift3/schema/copy_part_result.rng @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/swift3/test/unit/test_multi_upload.py b/swift3/test/unit/test_multi_upload.py index 3457f6bc..dad8cba0 100644 --- a/swift3/test/unit/test_multi_upload.py +++ b/swift3/test/unit/test_multi_upload.py @@ -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)