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


Python Response.headers方法代码示例

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


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

示例1: test_get_response_nonstreaming_ok

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_nonstreaming_ok(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sun, 09 Mar 2014 02:55:43 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY1)
        http_response.status_code = 403
        http_response.reason = 'Forbidden'
        http_response.request = Request()

        session = botocore.session.get_session()
        service_model = session.get_service_model('s3')
        operation_model = service_model.operation_model('ListObjects')

        self.assert_response_with_subset_metadata(
            response.get_response(operation_model, http_response)[1],
            {
                'ResponseMetadata': {
                    'RequestId': 'XXXXXXXXXXXXXXXX',
                    'HostId': 'AAAAAAAAAAAAAAAAAAA',
                    'HTTPStatusCode': 403
                },
                'Error': {
                    'Message': 'Access Denied',
                    'Code': 'AccessDenied'
                }
            })
开发者ID:pplu,项目名称:botocore,代码行数:33,代码来源:test_response.py

示例2: test_get_response_streaming_ng

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_streaming_ng(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sat, 08 Mar 2014 12:05:44 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY1)
        http_response.status_code = 403
        http_response.reason = 'Forbidden'

        session = botocore.session.get_session()
        service_model = session.get_service_model('s3')
        operation_model = service_model.operation_model('GetObject')

        self.assertEqual(
            response.get_response(operation_model, http_response)[1],
            {'Error': {'Message': 'Access Denied',
                       'Code': 'AccessDenied',},
             'ResponseMetadata': {'HostId': 'AAAAAAAAAAAAAAAAAAA',
                                  'RequestId': 'XXXXXXXXXXXXXXXX',
                                  'HTTPStatusCode': 403},
             }
        )
开发者ID:coreymaher,项目名称:botocore,代码行数:28,代码来源:test_response.py

示例3: test_get_response_streaming_ng

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_streaming_ng(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sat, 08 Mar 2014 12:05:44 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY1)
        http_response.status_code = 403
        http_response.reason = 'Forbidden'

        session = botocore.session.get_session()
        s3 = session.get_service('s3')
        operation = s3.get_operation('GetObject') # streaming operation

        self.assertEqual(
            response.get_response(session, operation, http_response)[1], 
            {u'Body': None,
              'Errors': [{'HostId': 'AAAAAAAAAAAAAAAAAAA',
                          'Message': 'Access Denied',
                          'Code': 'AccessDenied',
                          'RequestId': 'XXXXXXXXXXXXXXXX'}],
              'ResponseMetadata': {},
             u'Metadata': {}}
            )
开发者ID:Lumida,项目名称:botocore,代码行数:29,代码来源:test_response.py

示例4: test_get_response_nonstreaming_ng

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_nonstreaming_ng(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sat, 08 Mar 2014 12:05:44 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY2)
        http_response.status_code = 200
        http_response.reason = 'ok'
        http_response.request = Request()

        session = botocore.session.get_session()
        s3 = session.get_service('s3')
        operation = s3.get_operation('ListObjects') # non-streaming operation

        self.assertEqual(
            response.get_response(session, operation, http_response)[1], 
            {u'CommonPrefixes': [],
             u'Contents': [{u'ETag': '"00000000000000000000000000000000"',
                            u'Key': 'test.png',
                            u'LastModified': '2014-03-01T17:06:40.000Z',
                            u'Owner': {u'DisplayName': 'dummy',
                                       u'ID': 'AAAAAAAAAAAAAAAAAAA'},
                            u'Size': 6702,
                            u'StorageClass': 'STANDARD'}],
             u'IsTruncated': False,
             u'Marker': None,
             u'MaxKeys': 1000,
             u'Name': 'mybucket',
             u'Prefix': None,
             'ResponseMetadata': {}}
            )
开发者ID:Lumida,项目名称:botocore,代码行数:37,代码来源:test_response.py

示例5: test_get_response_nonstreaming_ok

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_nonstreaming_ok(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sun, 09 Mar 2014 02:55:43 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY1)
        http_response.status_code = 403
        http_response.reason = 'Forbidden'
        http_response.request = Request()

        session = botocore.session.get_session()
        s3 = session.get_service('s3')
        operation = s3.get_operation('ListObjects') # non-streaming operation

        self.assertEqual(
            response.get_response(session, operation, http_response)[1], 
            { 'ResponseMetadata': {},
              'Errors': [{'HostId': 'AAAAAAAAAAAAAAAAAAA',
                          'Message': 'Access Denied',
                          'Code': 'AccessDenied',
                          'RequestId': 'XXXXXXXXXXXXXXXX'}],
              'ResponseMetadata': {},
              u'CommonPrefixes': [],
              u'Contents': [],
              }
            )
开发者ID:Lumida,项目名称:botocore,代码行数:32,代码来源:test_response.py

示例6: test_get_response_streaming_ok

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_streaming_ok(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'image/png',
            'server': 'AmazonS3',
            'AcceptRanges': 'bytes',
            'transfer-encoding': 'chunked',
            'ETag': '"00000000000000000000000000000000"',
        }
        http_response.raw = six.BytesIO(b'\x89PNG\r\n\x1a\n\x00\x00')

        http_response.status_code = 200
        http_response.reason = 'OK'

        session = botocore.session.get_session()
        service_model = session.get_service_model('s3')
        operation_model = service_model.operation_model('GetObject')

        res = response.get_response(operation_model, http_response)
        self.assertTrue(isinstance(res[1]['Body'], response.StreamingBody))
        self.assertEqual(res[1]['ETag'],
                         '"00000000000000000000000000000000"')
开发者ID:coreymaher,项目名称:botocore,代码行数:24,代码来源:test_response.py

示例7: test_get_response_nonstreaming_ng

# 需要导入模块: from botocore.vendored.requests.models import Response [as 别名]
# 或者: from botocore.vendored.requests.models.Response import headers [as 别名]
    def test_get_response_nonstreaming_ng(self):
        http_response = Response()
        http_response.headers = {
            'content-type': 'application/xml',
            'date': 'Sat, 08 Mar 2014 12:05:44 GMT',
            'server': 'AmazonS3',
            'transfer-encoding': 'chunked',
            'x-amz-id-2': 'AAAAAAAAAAAAAAAAAAA',
            'x-amz-request-id': 'XXXXXXXXXXXXXXXX'}
        http_response.raw = six.BytesIO(XMLBODY2)
        http_response.status_code = 200
        http_response.reason = 'ok'
        http_response.request = Request()

        session = botocore.session.get_session()
        service_model = session.get_service_model('s3')
        operation_model = service_model.operation_model('ListObjects')

        self.assertEqual(
            response.get_response(operation_model, http_response)[1],
            {u'Contents': [{u'ETag': '"00000000000000000000000000000000"',
                            u'Key': 'test.png',
                            u'LastModified': datetime.datetime(2014, 3, 1, 17, 6, 40, tzinfo=tzutc()),
                            u'Owner': {u'DisplayName': 'dummy',
                                       u'ID': 'AAAAAAAAAAAAAAAAAAA'},
                            u'Size': 6702,
                            u'StorageClass': 'STANDARD'}],
             u'IsTruncated': False,
             u'Marker': "",
             u'MaxKeys': 1000,
             u'Name': 'mybucket',
             u'Prefix': "",
             'ResponseMetadata': {
                 'RequestId': 'XXXXXXXXXXXXXXXX',
                 'HostId': 'AAAAAAAAAAAAAAAAAAA',
                 'HTTPStatusCode': 200,
             }}
        )
开发者ID:coreymaher,项目名称:botocore,代码行数:40,代码来源:test_response.py


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