added quoting to X-Copied-From header

This commit is contained in:
John Dickinson
2010-10-27 10:52:00 -05:00
parent 7fd418c662
commit a12292892b
2 changed files with 26 additions and 1 deletions

View File

@@ -769,7 +769,8 @@ class ObjectController(Controller):
resp = self.best_response(req, statuses, reasons, bodies, 'Object PUT',
etag=etag)
if source_header:
resp.headers['X-Copied-From'] = source_header.split('/', 2)[2]
resp.headers['X-Copied-From'] = quote(
source_header.split('/', 2)[2])
for k, v in req.headers.items():
if k.lower().startswith('x-object-meta-'):
resp.headers[k] = v

View File

@@ -1076,6 +1076,18 @@ class TestObjectController(unittest.TestCase):
# acct cont obj obj obj
resp = controller.PUT(req)
self.assertEquals(resp.status_int, 201)
controller = proxy_server.ObjectController(self.app, 'account',
'container', 'object')
req = Request.blank('/a/c/o%%20o2',
environ={'REQUEST_METHOD': 'PUT'},
headers={'Content-Length': '0'})
self.app.update_request(req)
proxy_server.http_connect = \
fake_http_connect(200, 200, 201, 201, 201)
# acct cont obj obj obj
resp = controller.PUT(req)
self.assertEquals(resp.status_int, 201)
req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={'Content-Length': '0',
@@ -1112,6 +1124,18 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.status_int, 201)
self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2')
req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={'Content-Length': '0',
'X-Copy-From': 'c/o%%20o2'})
req.account = 'a'
proxy_server.http_connect = \
fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
# acct cont acct cont objc obj obj obj
self.app.memcache.store = {}
resp = controller.PUT(req)
self.assertEquals(resp.status_int, 201)
self.assertEquals(resp.headers['x-copied-from'], 'c/o%%20o2')
# repeat tests with leading /
req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={'Content-Length': '0',