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


Python AWSHTTPConnection.request方法代码示例

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


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

示例1: test_no_expect_header_set

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_no_expect_header_set(self):
     # Shows the server first sending a 100 continue response
     # then a 200 ok response.
     s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
     conn = AWSHTTPConnection('s3.amazonaws.com', 443)
     conn.sock = s
     conn.request('GET', '/bucket/foo', b'body')
     response = conn.getresponse()
     self.assertEqual(response.status, 200)
开发者ID:ballagas,项目名称:botocore,代码行数:11,代码来源:test_awsrequest.py

示例2: test_message_body_is_file_like_object

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_message_body_is_file_like_object(self):
     # Shows the server first sending a 100 continue response
     # then a 200 ok response.
     body = BytesIOWithLen(b'body contents')
     s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
     conn = AWSHTTPConnection('s3.amazonaws.com', 443)
     conn.sock = s
     conn.request('GET', '/bucket/foo', body)
     response = conn.getresponse()
     self.assertEqual(response.status, 200)
开发者ID:ballagas,项目名称:botocore,代码行数:12,代码来源:test_awsrequest.py

示例3: test_encodes_unicode_method_line

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_encodes_unicode_method_line(self):
     s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
     conn = AWSHTTPConnection('s3.amazonaws.com', 443)
     conn.sock = s
     # Note the combination of unicode 'GET' and
     # bytes 'Utf8-Header' value.
     conn.request(u'GET', '/bucket/foo', b'body',
                  headers={"Utf8-Header": b"\xe5\xb0\x8f"})
     response = conn.getresponse()
     self.assertEqual(response.status, 200)
开发者ID:Bazze,项目名称:botocore,代码行数:12,代码来源:test_awsrequest.py

示例4: test_expect_100_continue_returned

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_continue_returned(self):
     with patch('select.select') as select_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(b'HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         select_mock.return_value = ([s], [], [])
         conn.request('GET', '/bucket/foo', b'body', {'Expect': '100-continue'})
         response = conn.getresponse()
         # Now we should verify that our final response is the 200 OK
         self.assertEqual(response.status, 200)
开发者ID:ballagas,项目名称:botocore,代码行数:14,代码来源:test_awsrequest.py

示例5: test_expect_100_continue_returned

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_continue_returned(self):
     with patch('urllib3.util.wait_for_read') as wait_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(b'HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         wait_mock.return_value = True
         conn.request('GET', '/bucket/foo', b'body',
                      {'Expect': b'100-continue'})
         response = conn.getresponse()
         # Assert that we waited for the 100-continue response
         self.assertEqual(wait_mock.call_count, 1)
         # Now we should verify that our final response is the 200 OK
         self.assertEqual(response.status, 200)
开发者ID:boto,项目名称:botocore,代码行数:17,代码来源:test_awsrequest.py

示例6: test_expect_100_continue_no_response_from_server

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_continue_no_response_from_server(self):
     with patch('select.select') as select_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(
             b'HTTP/1.1 307 Temporary Redirect\r\n'
             b'Location: http://example.org\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         # By settings select_mock to return empty lists, this indicates
         # that the server did not send any response.  In this situation
         # we should just send the request anyways.
         select_mock.return_value = ([], [], [])
         conn.request('GET', '/bucket/foo', b'body', {'Expect': '100-continue'})
         response = conn.getresponse()
         self.assertEqual(response.status, 307)
开发者ID:ballagas,项目名称:botocore,代码行数:18,代码来源:test_awsrequest.py

示例7: test_expect_100_continue_sends_307

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_continue_sends_307(self):
     # This is the case where we send a 100 continue and the server
     # immediately sends a 307
     with patch('select.select') as select_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(
             b'HTTP/1.1 307 Temporary Redirect\r\n'
             b'Location: http://example.org\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         select_mock.return_value = ([s], [], [])
         conn.request('GET', '/bucket/foo', b'body', {'Expect': '100-continue'})
         response = conn.getresponse()
         # Now we should verify that our final response is the 307.
         self.assertEqual(response.status, 307)
开发者ID:ballagas,项目名称:botocore,代码行数:18,代码来源:test_awsrequest.py

示例8: test_handles_expect_100_with_different_reason_phrase

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_handles_expect_100_with_different_reason_phrase(self):
     with patch('select.select') as select_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(b'HTTP/1.1 100 (Continue)\r\n\r\nHTTP/1.1 200 OK\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         select_mock.return_value = ([s], [], [])
         conn.request('GET', '/bucket/foo', six.BytesIO(b'body'),
                      {'Expect': '100-continue', 'Content-Length': '4'})
         response = conn.getresponse()
         # Now we should verify that our final response is the 200 OK.
         self.assertEqual(response.status, 200)
         # Verify that we went the request body because we got a 100
         # continue.
         self.assertIn(b'body', s.sent_data)
开发者ID:Bazze,项目名称:botocore,代码行数:18,代码来源:test_awsrequest.py

示例9: test_expect_100_continue_no_response_from_server

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_continue_no_response_from_server(self):
     with patch('urllib3.util.wait_for_read') as wait_mock:
         # Shows the server first sending a 100 continue response
         # then a 200 ok response.
         s = FakeSocket(
             b'HTTP/1.1 307 Temporary Redirect\r\n'
             b'Location: http://example.org\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         # By settings wait_mock to return False, this indicates
         # that the server did not send any response.  In this situation
         # we should just send the request anyways.
         wait_mock.return_value = False
         conn.request('GET', '/bucket/foo', b'body',
                      {'Expect': b'100-continue'})
         # Assert that we waited for the 100-continue response
         self.assertEqual(wait_mock.call_count, 1)
         response = conn.getresponse()
         self.assertEqual(response.status, 307)
开发者ID:boto,项目名称:botocore,代码行数:21,代码来源:test_awsrequest.py

示例10: test_state_reset_on_connection_close

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
    def test_state_reset_on_connection_close(self):
        # This simulates what urllib3 does with connections
        # in its connection pool logic.
        with patch('urllib3.util.wait_for_read') as wait_mock:

            # First fast fail with a 500 response when we first
            # send the expect header.
            s = FakeSocket(b'HTTP/1.1 500 Internal Server Error\r\n')
            conn = AWSHTTPConnection('s3.amazonaws.com', 443)
            conn.sock = s
            wait_mock.return_value = True

            conn.request('GET', '/bucket/foo', b'body',
                        {'Expect': b'100-continue'})
            self.assertEqual(wait_mock.call_count, 1)
            response = conn.getresponse()
            self.assertEqual(response.status, 500)

            # Now what happens in urllib3 is that when the next
            # request comes along and this conection gets checked
            # out.  We see that the connection needs to be
            # reset.  So first the connection is closed.
            conn.close()

            # And then a new connection is established.
            new_conn = FakeSocket(
                b'HTTP/1.1 100 (Continue)\r\n\r\nHTTP/1.1 200 OK\r\n')
            conn.sock = new_conn

            # And we make a request, we should see the 200 response
            # that was sent back.
            wait_mock.return_value = True

            conn.request('GET', '/bucket/foo', b'body',
                        {'Expect': b'100-continue'})
            # Assert that we waited for the 100-continue response
            self.assertEqual(wait_mock.call_count, 2)
            response = conn.getresponse()
            # This should be 200.  If it's a 500 then
            # the prior response was leaking into our
            # current response.,
            self.assertEqual(response.status, 200)
开发者ID:boto,项目名称:botocore,代码行数:44,代码来源:test_awsrequest.py

示例11: test_expect_100_sends_connection_header

# 需要导入模块: from botocore.awsrequest import AWSHTTPConnection [as 别名]
# 或者: from botocore.awsrequest.AWSHTTPConnection import request [as 别名]
 def test_expect_100_sends_connection_header(self):
     # When using squid as an HTTP proxy, it will also send
     # a Connection: keep-alive header back with the 100 continue
     # response.  We need to ensure we handle this case.
     with patch('select.select') as select_mock:
         # Shows the server first sending a 100 continue response
         # then a 500 response.  We're picking 500 to confirm we
         # actually parse the response instead of getting the
         # default status of 200 which happens when we can't parse
         # the response.
         s = FakeSocket(b'HTTP/1.1 100 Continue\r\n'
                        b'Connection: keep-alive\r\n'
                        b'\r\n'
                        b'HTTP/1.1 500 Internal Service Error\r\n')
         conn = AWSHTTPConnection('s3.amazonaws.com', 443)
         conn.sock = s
         select_mock.return_value = ([s], [], [])
         conn.request('GET', '/bucket/foo', b'body',
                      {'Expect': '100-continue'})
         response = conn.getresponse()
         self.assertEqual(response.status, 500)
开发者ID:Bazze,项目名称:botocore,代码行数:23,代码来源:test_awsrequest.py


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