Fix for attempted COPY of objects gt MAX_FILE_SIZE
If X-Copy-From is a manifest object, it can be bigger than MAX_FILE_SIZE. Currently this fails with 503. It should be 413. Bug #1158279 Change-Id: I7ec16088046c84e42d5be9c865e1338eb07845b6
This commit is contained in:
parent
3cf99ecc33
commit
7df4323745
@ -848,6 +848,8 @@ class ObjectController(Controller):
|
||||
# CONTAINER_LISTING_LIMIT segments in a segmented object. In
|
||||
# this case, we're going to refuse to do the server-side copy.
|
||||
return HTTPRequestEntityTooLarge(request=req)
|
||||
if new_req.content_length > MAX_FILE_SIZE:
|
||||
return HTTPRequestEntityTooLarge(request=req)
|
||||
new_req.etag = source_resp.etag
|
||||
# we no longer need the X-Copy-From header
|
||||
del new_req.headers['X-Copy-From']
|
||||
|
@ -2430,6 +2430,28 @@ class TestObjectController(unittest.TestCase):
|
||||
'testing')
|
||||
self.assertEquals(resp.headers.get('x-object-meta-ours'), 'okay')
|
||||
|
||||
# copy-from object is too large to fit in target object
|
||||
req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'Content-Length': '0',
|
||||
'X-Copy-From': '/c/o'})
|
||||
self.app.update_request(req)
|
||||
|
||||
class LargeResponseBody(object):
|
||||
|
||||
def __len__(self):
|
||||
return MAX_FILE_SIZE + 1
|
||||
|
||||
def __getitem__(self, key):
|
||||
return ''
|
||||
|
||||
copy_from_obj_body = LargeResponseBody()
|
||||
set_http_connect(200, 200, 200, 200, 200, 201, 201, 201,
|
||||
body=copy_from_obj_body)
|
||||
self.app.memcache.store = {}
|
||||
resp = controller.PUT(req)
|
||||
self.assertEquals(resp.status_int, 413)
|
||||
|
||||
|
||||
def test_COPY(self):
|
||||
with save_globals():
|
||||
controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o')
|
||||
@ -2540,6 +2562,26 @@ class TestObjectController(unittest.TestCase):
|
||||
'testing')
|
||||
self.assertEquals(resp.headers.get('x-object-meta-ours'), 'okay')
|
||||
|
||||
req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
|
||||
headers={'Destination': '/c/o'})
|
||||
self.app.update_request(req)
|
||||
|
||||
class LargeResponseBody(object):
|
||||
|
||||
def __len__(self):
|
||||
return MAX_FILE_SIZE + 1
|
||||
|
||||
def __getitem__(self, key):
|
||||
return ''
|
||||
|
||||
copy_from_obj_body = LargeResponseBody()
|
||||
set_http_connect(200, 200, 200, 200, 200, 201, 201, 201,
|
||||
body=copy_from_obj_body)
|
||||
self.app.memcache.store = {}
|
||||
resp = controller.COPY(req)
|
||||
self.assertEquals(resp.status_int, 413)
|
||||
|
||||
|
||||
def test_COPY_newest(self):
|
||||
with save_globals():
|
||||
controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o')
|
||||
|
Loading…
x
Reference in New Issue
Block a user