~ubuntu-branches/ubuntu/raring/swift/raring-security

« back to all changes in this revision

Viewing changes to swift/account/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:
35
35
    HTTPCreated, HTTPForbidden, HTTPInternalServerError, \
36
36
    HTTPMethodNotAllowed, HTTPNoContent, HTTPNotFound, \
37
37
    HTTPPreconditionFailed, HTTPConflict, Request, Response, \
38
 
    HTTPInsufficientStorage
 
38
    HTTPInsufficientStorage, HTTPNotAcceptable
39
39
 
40
40
 
41
41
DATADIR = 'accounts'
182
182
        if get_param(req, 'format'):
183
183
            req.accept = FORMAT2CONTENT_TYPE.get(
184
184
                get_param(req, 'format').lower(), FORMAT2CONTENT_TYPE['plain'])
185
 
        try:
186
 
            headers['Content-Type'] = req.accept.best_match(
187
 
                ['text/plain', 'application/json', 'application/xml',
188
 
                 'text/xml'],
189
 
                default_match='text/plain')
190
 
        except AssertionError, err:
191
 
            return HTTPBadRequest(body='bad accept header: %s' % req.accept,
192
 
                                  content_type='text/plain', request=req)
 
185
        headers['Content-Type'] = req.accept.best_match(
 
186
            ['text/plain', 'application/json', 'application/xml', 'text/xml'])
 
187
        if not headers['Content-Type']:
 
188
            return HTTPNotAcceptable(request=req)
193
189
        return HTTPNoContent(request=req, headers=headers, charset='utf-8')
194
190
 
195
191
    @public
242
238
        if query_format:
243
239
            req.accept = FORMAT2CONTENT_TYPE.get(query_format.lower(),
244
240
                                                 FORMAT2CONTENT_TYPE['plain'])
245
 
        try:
246
 
            out_content_type = req.accept.best_match(
247
 
                ['text/plain', 'application/json', 'application/xml',
248
 
                 'text/xml'],
249
 
                default_match='text/plain')
250
 
        except AssertionError, err:
251
 
            return HTTPBadRequest(body='bad accept header: %s' % req.accept,
252
 
                                  content_type='text/plain', request=req)
 
241
        out_content_type = req.accept.best_match(
 
242
            ['text/plain', 'application/json', 'application/xml', 'text/xml'])
 
243
        if not out_content_type:
 
244
            return HTTPNotAcceptable(request=req)
253
245
        account_list = broker.list_containers_iter(limit, marker, end_marker,
254
246
                                                   prefix, delimiter)
255
247
        if out_content_type == 'application/json':
342
334
        req = Request(env)
343
335
        self.logger.txn_id = req.headers.get('x-trans-id', None)
344
336
        if not check_utf8(req.path_info):
345
 
            res = HTTPPreconditionFailed(body='Invalid UTF8')
 
337
            res = HTTPPreconditionFailed(body='Invalid UTF8 or contains NULL')
346
338
        else:
347
339
            try:
348
340
                # disallow methods which are not publicly accessible