本文整理汇总了Python中werkzeug.wsgi.LimitedStream方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.LimitedStream方法的具体用法?Python wsgi.LimitedStream怎么用?Python wsgi.LimitedStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.wsgi
的用法示例。
在下文中一共展示了wsgi.LimitedStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from werkzeug import wsgi [as 别名]
# 或者: from werkzeug.wsgi import LimitedStream [as 别名]
def __call__(self, environ, start_response):
limit = min(self.maximum_size, int(environ.get('CONTENT_LENGTH') or 0))
environ['wsgi.input'] = LimitedStream(environ['wsgi.input'], limit)
return self.app(environ, start_response)
示例2: test_other_method_payload
# 需要导入模块: from werkzeug import wsgi [as 别名]
# 或者: from werkzeug.wsgi import LimitedStream [as 别名]
def test_other_method_payload(self):
data = b'Hello World'
req = wrappers.Request.from_values(input_stream=BytesIO(data),
content_length=len(data),
content_type='text/plain',
method='WHAT_THE_FUCK')
self.assert_equal(req.get_data(), data)
self.assert_is_instance(req.stream, LimitedStream)
示例3: test_limited_stream_disconnection
# 需要导入模块: from werkzeug import wsgi [as 别名]
# 或者: from werkzeug.wsgi import LimitedStream [as 别名]
def test_limited_stream_disconnection(self):
io = BytesIO(b'A bit of content')
# disconnect detection on out of bytes
stream = wsgi.LimitedStream(io, 255)
with self.assert_raises(ClientDisconnected):
stream.read()
# disconnect detection because file close
io = BytesIO(b'x' * 255)
io.close()
stream = wsgi.LimitedStream(io, 255)
with self.assert_raises(ClientDisconnected):
stream.read()