~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to swift/container/server.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
39
39
    HTTPCreated, HTTPInternalServerError, HTTPNoContent, HTTPNotFound, \
40
40
    HTTPPreconditionFailed, HTTPMethodNotAllowed, Request, Response, \
41
 
    HTTPInsufficientStorage
 
41
    HTTPInsufficientStorage, HTTPNotAcceptable
42
42
 
43
43
DATADIR = 'containers'
44
44
 
280
280
        if get_param(req, 'format'):
281
281
            req.accept = FORMAT2CONTENT_TYPE.get(
282
282
                get_param(req, 'format').lower(), FORMAT2CONTENT_TYPE['plain'])
283
 
        try:
284
 
            headers['Content-Type'] = req.accept.best_match(
285
 
                ['text/plain', 'application/json', 'application/xml',
286
 
                 'text/xml'],
287
 
                default_match='text/plain')
288
 
        except AssertionError, err:
289
 
            return HTTPBadRequest(body='bad accept header: %s' % req.accept,
290
 
                                  content_type='text/plain', request=req)
 
283
        headers['Content-Type'] = req.accept.best_match(
 
284
            ['text/plain', 'application/json', 'application/xml', 'text/xml'])
 
285
        if not headers['Content-Type']:
 
286
            return HTTPNotAcceptable(request=req)
291
287
        return HTTPNoContent(request=req, headers=headers, charset='utf-8')
292
288
 
293
289
    @public
344
340
        if query_format:
345
341
            req.accept = FORMAT2CONTENT_TYPE.get(query_format.lower(),
346
342
                                                 FORMAT2CONTENT_TYPE['plain'])
347
 
        try:
348
 
            out_content_type = req.accept.best_match(
349
 
                ['text/plain', 'application/json', 'application/xml',
350
 
                 'text/xml'],
351
 
                default_match='text/plain')
352
 
        except AssertionError, err:
353
 
            return HTTPBadRequest(body='bad accept header: %s' % req.accept,
354
 
                                  content_type='text/plain', request=req)
 
343
        out_content_type = req.accept.best_match(
 
344
            ['text/plain', 'application/json', 'application/xml', 'text/xml'])
 
345
        if not out_content_type:
 
346
            return HTTPNotAcceptable(request=req)
355
347
        container_list = broker.list_objects_iter(limit, marker, end_marker,
356
348
                                                  prefix, delimiter, path)
357
349
        if out_content_type == 'application/json':
469
461
        req = Request(env)
470
462
        self.logger.txn_id = req.headers.get('x-trans-id', None)
471
463
        if not check_utf8(req.path_info):
472
 
            res = HTTPPreconditionFailed(body='Invalid UTF8')
 
464
            res = HTTPPreconditionFailed(body='Invalid UTF8 or contains NULL')
473
465
        else:
474
466
            try:
475
467
                # disallow methods which have not been marked 'public'