Esempio n. 1
0
 def setUp(self, conf=None):
     super(BaseTestCase, self).setUp()
     if conf is None:
         self.conf = cfg.ConfigOpts()
     else:
         self.conf = conf
     self.fconf = cfgfilter.ConfigFilter(self.conf)
Esempio n. 2
0
_oldopts = [
    cfg.DeprecatedOpt('osapi_max_request_body_size', group='DEFAULT'),
    cfg.DeprecatedOpt('max_request_body_size', group='DEFAULT')
]

_opts = [
    # default request size is 112k
    cfg.IntOpt('max_request_body_size',
               default=114688,
               help='The maximum body size for each '
               ' request, in bytes.',
               deprecated_opts=_oldopts)
]

CONF = cfgfilter.ConfigFilter(cfg.CONF)
CONF.register_opts(_opts, group='oslo_middleware')


class LimitingReader(object):
    """Reader to limit the size of an incoming request."""
    def __init__(self, data, limit):
        """Initiates LimitingReader object.

        :param data: Underlying data object
        :param limit: maximum number of bytes the reader should allow
        """
        self.data = data
        self.limit = limit
        self.bytes_read = 0