本文整理匯總了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()