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


Python Server._additional_headers方法代码示例

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


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

示例1: test_should_override_global_headers

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _additional_headers [as 别名]
    def test_should_override_global_headers(self):
        # given
        client = Server('http://localhost:{0}'.format(self.port), verbose=1,
                        headers={'X-Test' : 'Global'})

        # when
        with self.captured_headers() as headers:
            with client._additional_headers({'X-Test' : 'Method'}) as cl:
                response = cl.ping()
                self.assertTrue(response)

        # then
        self.assertTrue('x-test' in headers)
        self.assertEqual(headers['x-test'], 'Method')
开发者ID:Zectbumo,项目名称:jsonrpclib,代码行数:16,代码来源:tests.py

示例2: test_should_add_custom_headers_to_methods

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _additional_headers [as 别名]
    def test_should_add_custom_headers_to_methods(self):
        # given
        client = Server('http://localhost:{0}'.format(self.port), verbose=1)

        # when
        with self.captured_headers() as headers:
            with client._additional_headers({'X-Method' : 'Method'}) as cl:
                response = cl.ping()

            self.assertTrue(response)

        # then
        self.assertTrue('x-method' in headers)
        self.assertEqual(headers['x-method'], 'Method')
开发者ID:Zectbumo,项目名称:jsonrpclib,代码行数:16,代码来源:tests.py

示例3: test_should_allow_to_nest_additional_header_blocks

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _additional_headers [as 别名]
    def test_should_allow_to_nest_additional_header_blocks(self):
        # given
        client = Server('http://localhost:%d' % self.port, verbose=1)

        # when
        with client._additional_headers({'X-Level-1' : '1'}) as cl_level1:
            with self.captured_headers() as headers1:
                response = cl_level1.ping()
                self.assertTrue(response)

            with cl_level1._additional_headers({'X-Level-2' : '2'}) as cl:
                with self.captured_headers() as headers2:
                    response = cl.ping()
                    self.assertTrue(response)

        # then
        self.assertTrue('x-level-1' in headers1)
        self.assertEqual(headers1['x-level-1'], '1')

        self.assertTrue('x-level-1' in headers2)
        self.assertEqual(headers1['x-level-1'], '1')
        self.assertTrue('x-level-2' in headers2)
        self.assertEqual(headers2['x-level-2'], '2')
开发者ID:Zectbumo,项目名称:jsonrpclib,代码行数:25,代码来源:tests.py


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