~ubuntu-branches/ubuntu/saucy/swift/saucy-security

« back to all changes in this revision

Viewing changes to swift/common/middleware/bulk.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-04-02 09:06:48 UTC
  • mfrom: (1.2.18)
  • Revision ID: package-import@ubuntu.com-20130402090648-dq5fc3iy8hfoq9fq
Tags: 1.8.0~rc2-0ubuntu1
New usptream release candidate for grizzly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from swift.common.swob import Request, HTTPBadGateway, \
20
20
    HTTPCreated, HTTPBadRequest, HTTPNotFound, HTTPUnauthorized, HTTPOk, \
21
21
    HTTPPreconditionFailed, HTTPRequestEntityTooLarge, HTTPNotAcceptable, \
22
 
    wsgify
 
22
    HTTPLengthRequired, wsgify
23
23
from swift.common.utils import json, TRUE_VALUES
24
24
from swift.common.constraints import check_utf8, MAX_FILE_SIZE
25
25
from swift.common.http import HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, \
191
191
        objs_to_delete = []
192
192
        if req.content_length is None and \
193
193
                req.headers.get('transfer-encoding', '').lower() != 'chunked':
194
 
            raise HTTPBadRequest('Invalid request: no content sent.')
 
194
            raise HTTPLengthRequired(request=req)
195
195
 
196
196
        while data_remaining:
197
 
            if len(objs_to_delete) > self.max_deletes_per_request:
198
 
                raise HTTPRequestEntityTooLarge(
199
 
                    'Maximum Bulk Deletes: %d per request' %
200
 
                    self.max_deletes_per_request)
201
197
            if '\n' in line:
202
198
                obj_to_delete, line = line.split('\n', 1)
203
199
                objs_to_delete.append(unquote(obj_to_delete))
209
205
                    data_remaining = False
210
206
                    if line.strip():
211
207
                        objs_to_delete.append(unquote(line))
 
208
            if len(objs_to_delete) > self.max_deletes_per_request:
 
209
                raise HTTPRequestEntityTooLarge(
 
210
                    'Maximum Bulk Deletes: %d per request' %
 
211
                    self.max_deletes_per_request)
212
212
            if len(line) > MAX_PATH_LENGTH * 2:
213
213
                raise HTTPBadRequest('Invalid File Name')
214
214
        return objs_to_delete
295
295
            return HTTPNotAcceptable(request=req)
296
296
        if req.content_length is None and \
297
297
                req.headers.get('transfer-encoding', '').lower() != 'chunked':
298
 
            return HTTPBadRequest('Invalid request: no content sent.')
 
298
            return HTTPLengthRequired(request=req)
299
299
        try:
300
300
            vrs, account, extract_base = req.split_path(2, 3, True)
301
301
        except ValueError: