本文整理匯總了Python中werkzeug.Response.direct_passthrough方法的典型用法代碼示例。如果您正苦於以下問題:Python Response.direct_passthrough方法的具體用法?Python Response.direct_passthrough怎麽用?Python Response.direct_passthrough使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類werkzeug.Response
的用法示例。
在下文中一共展示了Response.direct_passthrough方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_wrapper_internals
# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import direct_passthrough [as 別名]
def test_wrapper_internals():
"""Test internals of the wrappers"""
from werkzeug import Request
req = Request.from_values(data={'foo': 'bar'}, method='POST')
req._load_form_data()
assert req.form.to_dict() == {'foo': 'bar'}
# second call does not break
req._load_form_data()
assert req.form.to_dict() == {'foo': 'bar'}
# check reprs
assert repr(req) == "<Request 'http://localhost/' [POST]>"
resp = Response()
assert repr(resp) == '<Response 0 bytes [200 OK]>'
resp.data = 'Hello World!'
assert repr(resp) == '<Response 12 bytes [200 OK]>'
resp.response = iter(['Test'])
assert repr(resp) == '<Response streamed [200 OK]>'
# unicode data does not set content length
response = Response([u'Hällo Wörld'])
headers = response.get_wsgi_headers(create_environ())
assert 'Content-Length' not in headers
response = Response(['Hällo Wörld'])
headers = response.get_wsgi_headers(create_environ())
assert 'Content-Length' in headers
# check for internal warnings
print 'start'
filterwarnings('error', category=Warning)
response = Response()
environ = create_environ()
response.response = 'What the...?'
assert_raises(Warning, lambda: list(response.iter_encoded()))
assert_raises(Warning, lambda: list(response.get_app_iter(environ)))
response.direct_passthrough = True
assert_raises(Warning, lambda: list(response.iter_encoded()))
assert_raises(Warning, lambda: list(response.get_app_iter(environ)))
resetwarnings()