本文整理匯總了Python中tornado.wsgi.input方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgi.input方法的具體用法?Python wsgi.input怎麽用?Python wsgi.input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.wsgi
的用法示例。
在下文中一共展示了wsgi.input方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __setitem__
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def __setitem__(self, key, value):
""" Change an environ value and clear all caches that depend on it. """
if self.environ.get('bottle.request.readonly'):
raise KeyError('The environ dictionary is read-only.')
self.environ[key] = value
todelete = ()
if key == 'wsgi.input':
todelete = ('body', 'forms', 'files', 'params', 'post', 'json')
elif key == 'QUERY_STRING':
todelete = ('query', 'params')
elif key.startswith('HTTP_'):
todelete = ('headers', 'cookies')
for key in todelete:
self.environ.pop('bottle.request.'+key, None)
示例2: _body
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def _body(self):
try:
read_func = self.environ['wsgi.input'].read
except KeyError:
self.environ['wsgi.input'] = BytesIO()
return self.environ['wsgi.input']
body_iter = self._iter_chunked if self.chunked else self._iter_body
body, body_size, is_temp_file = BytesIO(), 0, False
for part in body_iter(read_func, self.MEMFILE_MAX):
body.write(part)
body_size += len(part)
if not is_temp_file and body_size > self.MEMFILE_MAX:
body, tmp = TemporaryFile(mode='w+b'), body
body.write(tmp.getvalue())
del tmp
is_temp_file = True
self.environ['wsgi.input'] = body
body.seek(0)
return body
示例3: __setitem__
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def __setitem__(self, key, value):
""" Change an environ value and clear all caches that depend on it. """
if self.environ.get('bottle.request.readonly'):
raise KeyError('The environ dictionary is read-only.')
self.environ[key] = value
todelete = ()
if key == 'wsgi.input':
todelete = ('body', 'forms', 'files', 'params', 'post', 'json')
elif key == 'QUERY_STRING':
todelete = ('query', 'params')
elif key.startswith('HTTP_'):
todelete = ('headers', 'cookies')
for key in todelete:
self.environ.pop('bottle.request.' + key, None)
示例4: body
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def body(self):
""" The HTTP request body as a seekable buffer object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`.
"""
if self._body is None:
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input']
self._body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: #TODO: Wrong content_length. Error? Do nothing?
break
self._body.write(part)
maxread -= len(part)
self.environ['wsgi.input'] = self._body
self._body.seek(0)
return self._body
示例5: body
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def body(self):
""" The HTTP request body as a seekable buffer object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`.
"""
if self._body is None:
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input']
self._body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: #TODO: Wrong content_length. Error? Do nothing?
break
self._body.write(part)
maxread -= len(part)
self.environ['wsgi.input'] = self._body
self._body.seek(0)
return self._body
示例6: _body
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def _body(self):
""" The HTTP request body as a seekable file-like object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`.
"""
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input']
body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: break
body.write(part)
maxread -= len(part)
self.environ['wsgi.input'] = body
body.seek(0)
return body
示例7: _body
# 需要導入模塊: from tornado import wsgi [as 別名]
# 或者: from tornado.wsgi import input [as 別名]
def _body(self):
body_iter = self._iter_chunked if self.chunked else self._iter_body
read_func = self.environ['wsgi.input'].read
body, body_size, is_temp_file = BytesIO(), 0, False
for part in body_iter(read_func, self.MEMFILE_MAX):
body.write(part)
body_size += len(part)
if not is_temp_file and body_size > self.MEMFILE_MAX:
body, tmp = TemporaryFile(mode='w+b'), body
body.write(tmp.getvalue())
del tmp
is_temp_file = True
self.environ['wsgi.input'] = body
body.seek(0)
return body