本文整理汇总了Python中botocore.awsrequest.AWSHTTPConnection._tunnel_headers方法的典型用法代码示例。如果您正苦于以下问题:Python AWSHTTPConnection._tunnel_headers方法的具体用法?Python AWSHTTPConnection._tunnel_headers怎么用?Python AWSHTTPConnection._tunnel_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botocore.awsrequest.AWSHTTPConnection
的用法示例。
在下文中一共展示了AWSHTTPConnection._tunnel_headers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_tunneled_connection
# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import _tunnel_headers [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