Fix response of PUT Object Copy requests

Current Swift3 does not return response body.
Also, response body that should be returned and headers are incorrect.

So, I added the following fixes.
 - fix Swift3 to retrun response body
 - add LastModified element to response body
 - change the value of Content-Type in response headers to application/xml
 - delete Etag from response headers

Also, this patch is related to the following patch.
 - https://review.openstack.org/#/c/126403

Change-Id: I41f6a4ed2445a1473cd766b0fe60d6894288b7dd
This commit is contained in:
Naoto Nishizono
2015-01-09 18:07:02 +09:00
parent e53b5d41db
commit ace6572c4b
2 changed files with 51 additions and 31 deletions

View File

@@ -17,8 +17,7 @@ from swift.common.http import HTTP_OK
from swift.common.swob import Range, content_range_header_value
from swift3.controllers.base import Controller
from swift3.response import HTTPOk, S3NotImplemented, InvalidRange,\
HTTPPartialContent
from swift3.response import S3NotImplemented, InvalidRange, HTTPPartialContent
from swift3.etree import Element, SubElement, tostring
@@ -99,9 +98,12 @@ class ObjectController(Controller):
if 'X-Amz-Copy-Source' in req.headers:
elem = Element('CopyObjectResult')
SubElement(elem, 'LastModified').text = \
resp.last_modified.isoformat()[:-6] + '.000Z'
SubElement(elem, 'ETag').text = '"%s"' % resp.etag
body = tostring(elem, use_s3ns=False)
return HTTPOk(body=body, headers=resp.headers)
resp.body = tostring(elem)
resp.headers['Content-Type'] = 'application/xml'
resp.etag = None
resp.status = HTTP_OK
return resp