bucket: make max_bucket_listing configurable
With this patch, users can limit the maximum number of objects returned in the GET Bucket response. The default is 1000, which is the same value as AWS S3 uses. Change-Id: I70f9aece8fa3e2d14ed02d831c560bc3d4feb172
This commit is contained in:
@@ -29,6 +29,10 @@ use = egg:swift3#swift3
|
||||
# GET Bucket location API.
|
||||
# location = US
|
||||
#
|
||||
# Set the default maximum number of objects returned in the GET Bucket
|
||||
# response.
|
||||
# max_bucket_listing = 1000
|
||||
#
|
||||
# Specify a host name of your Swift cluster. This enables virtual-hosted style
|
||||
# requests.
|
||||
# storage_domain =
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
# Global config dictionary. The default values can be defined here.
|
||||
CONF = {
|
||||
'location': 'US',
|
||||
'max_bucket_listing': 1000,
|
||||
'storage_domain': '',
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ from swift3.controllers.acl import add_canonical_user, swift_acl_translate
|
||||
from swift3.etree import Element, SubElement, tostring
|
||||
from swift3.response import HTTPOk, S3NotImplemented, InvalidArgument
|
||||
|
||||
MAX_BUCKET_LISTING = 1000
|
||||
from swift3.cfg import CONF
|
||||
|
||||
|
||||
class BucketController(Controller):
|
||||
@@ -45,8 +45,8 @@ class BucketController(Controller):
|
||||
if req.params.get('max-keys').isdigit() is False:
|
||||
raise InvalidArgument('max-keys', req.params['max-keys'])
|
||||
|
||||
max_keys = min(int(req.params.get('max-keys', MAX_BUCKET_LISTING)),
|
||||
MAX_BUCKET_LISTING)
|
||||
max_keys = int(req.params.get('max-keys', CONF['max_bucket_listing']))
|
||||
max_keys = min(max_keys, CONF['max_bucket_listing'])
|
||||
|
||||
query = {
|
||||
'format': 'json',
|
||||
|
||||
@@ -61,8 +61,6 @@ from swift3.request import Request
|
||||
from swift3.response import ErrorResponse, InternalError, MethodNotAllowed
|
||||
from swift3.cfg import CONF
|
||||
|
||||
MAX_BUCKET_LISTING = 1000
|
||||
|
||||
# List of sub-resources that must be maintained as part of the HMAC
|
||||
# signature string.
|
||||
ALLOWED_SUB_RESOURCES = sorted([
|
||||
|
||||
Reference in New Issue
Block a user