当前位置: 首页>>代码示例>>Python>>正文


Python Response.from_app方法代码示例

本文整理汇总了Python中werkzeug.Response.from_app方法的典型用法代码示例。如果您正苦于以下问题:Python Response.from_app方法的具体用法?Python Response.from_app怎么用?Python Response.from_app使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.Response的用法示例。


在下文中一共展示了Response.from_app方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_path_info_from_request_uri_fix

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_path_info_from_request_uri_fix():
    """Test the PathInfoFromRequestUriFix fixer"""
    app = fixers.PathInfoFromRequestUriFix(path_check_app)
    for key in 'REQUEST_URI', 'REQUEST_URL', 'UNENCODED_URL':
        env = dict(create_environ(), SCRIPT_NAME='/test', PATH_INFO='/?????')
        env[key] = '/test/foo%25bar?drop=this'
        response = Response.from_app(app, env)
        assert response.data == 'PATH_INFO: /foo%bar\nSCRIPT_NAME: /test'
开发者ID:AndryulE,项目名称:kitsune,代码行数:10,代码来源:test_fixers.py

示例2: test_lighttpd_cgi_root_fix

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_lighttpd_cgi_root_fix():
    """Test the LighttpdCGIRootFix fixer"""
    app = fixers.LighttpdCGIRootFix(path_check_app)
    response = Response.from_app(app, dict(create_environ(),
        SCRIPT_NAME='/foo',
        PATH_INFO='/bar'
    ))
    assert response.data == 'PATH_INFO: /foo/bar\nSCRIPT_NAME: '
开发者ID:AndryulE,项目名称:kitsune,代码行数:10,代码来源:test_fixers.py

示例3: test_fix_headers_in_response

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_fix_headers_in_response():
    """Make sure fix_headers still works for backwards compatibility"""
    from werkzeug import Response
    class MyResponse(Response):
        def fix_headers(self, environ):
            Response.fix_headers(self, environ)
            self.headers['x-foo'] = "meh"
    myresp = MyResponse('Foo')
    resp = Response.from_app(myresp, create_environ(method='GET'))
    assert resp.headers['x-foo'] == 'meh'
    assert resp.data == 'Foo'
开发者ID:t11e,项目名称:werkzeug,代码行数:13,代码来源:test_compat.py

示例4: test_header_rewriter_fix

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_header_rewriter_fix():
    """Test the HeaderRewriterFix fixer"""
    @Request.application
    def application(request):
        return Response("", headers=[
            ('X-Foo', 'bar')
        ])
    application = fixers.HeaderRewriterFix(application, ('X-Foo',), (('X-Bar', '42'),))
    response = Response.from_app(application, create_environ())
    assert response.headers['Content-Type'] == 'text/plain; charset=utf-8'
    assert 'X-Foo' not in response.headers
    assert response.headers['X-Bar'] == '42'
开发者ID:AndryulE,项目名称:kitsune,代码行数:14,代码来源:test_fixers.py

示例5: test_proxy_fix

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_proxy_fix():
    """Test the ProxyFix fixer"""
    @fixers.ProxyFix
    @Request.application
    def app(request):
        return Response('%s|%s' % (
            request.remote_addr,
            # do not use request.host as this fixes too :)
            request.environ['HTTP_HOST']
        ))
    response = Response.from_app(app, dict(create_environ(),
        HTTP_X_FORWARDED_HOST='example.com',
        HTTP_X_FORWARDED_FOR='1.2.3.4, 5.6.7.8',
        REMOTE_ADDR='127.0.0.1',
        HTTP_HOST='fake'
    ))
    assert response.data == '1.2.3.4|example.com'
开发者ID:AndryulE,项目名称:kitsune,代码行数:19,代码来源:test_fixers.py

示例6: test_fix_headers_in_response

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
def test_fix_headers_in_response():
    """Make sure fix_headers still works for backwards compatibility"""
    # ignore some warnings werkzeug emits for backwards compat
    for msg in ['called into deprecated fix_headers',
                'fix_headers changed behavior']:
        warnings.filterwarnings('ignore', message=msg,
                                category=DeprecationWarning)

    from werkzeug import Response
    class MyResponse(Response):
        def fix_headers(self, environ):
            Response.fix_headers(self, environ)
            self.headers['x-foo'] = "meh"
    myresp = MyResponse('Foo')
    resp = Response.from_app(myresp, create_environ(method='GET'))
    assert resp.headers['x-foo'] == 'meh'
    assert resp.data == 'Foo'

    warnings.resetwarnings()
开发者ID:marchon,项目名称:checkinmapper,代码行数:21,代码来源:test_compat.py

示例7: __call__

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import from_app [as 别名]
 def __call__(self, request, **kwargs):
   self.request = request
   response = Response.from_app(self.app, self.request.environ)
   return response
开发者ID:IanLewis,项目名称:kay,代码行数:6,代码来源:wrapper.py


注:本文中的werkzeug.Response.from_app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。