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


Python AWSHTTPConnection._tunnel_port方法代码示例

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


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

示例1: create_tunneled_connection

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import _tunnel_port [as 别名]
    def create_tunneled_connection(self, url, port, response):
        s = FakeSocket(response)
        conn = AWSHTTPConnection(url, port)
        conn.sock = s
        conn._tunnel_host = url
        conn._tunnel_port = port
        conn._tunnel_headers = {'key': 'value'}

        # Create a mock response.
        self.mock_response = Mock()
        self.mock_response.fp = Mock()

        # Imitate readline function by creating a list to be sent as
        # a side effect of the mocked readline to be able to track how the
        # response is processed in ``_tunnel()``.
        delimeter = b'\r\n'
        side_effect = []
        response_components = response.split(delimeter)
        for i in range(len(response_components)):
            new_component = response_components[i]
            # Only add the delimeter on if it is not the last component
            # which should be an empty string.
            if i != len(response_components) - 1:
                new_component += delimeter
            side_effect.append(new_component)

        self.mock_response.fp.readline.side_effect = side_effect

        response_components = response.split(b' ')
        self.mock_response._read_status.return_value = (
            response_components[0], int(response_components[1]),
            response_components[2]
        )
        conn.response_class = Mock()
        conn.response_class.return_value = self.mock_response
        return conn
开发者ID:ballagas,项目名称:botocore,代码行数:38,代码来源:test_awsrequest.py


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