當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。