本文整理匯總了Python中botocore.awsrequest.AWSHTTPConnection._tunnel_host方法的典型用法代碼示例。如果您正苦於以下問題:Python AWSHTTPConnection._tunnel_host方法的具體用法?Python AWSHTTPConnection._tunnel_host怎麽用?Python AWSHTTPConnection._tunnel_host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類botocore.awsrequest.AWSHTTPConnection
的用法示例。
在下文中一共展示了AWSHTTPConnection._tunnel_host方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_tunneled_connection
# 需要導入模塊: from botocore.awsrequest import AWSHTTPConnection [as 別名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import _tunnel_host [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