Did I find the right examples for you? yes no

All Samples(8)  |  Call(7)  |  Derive(0)  |  Import(1)

        def get_response(session, operation, http_response):
    encoding = 'utf-8'
    if http_response.encoding:
        encoding = http_response.encoding
    content_type = http_response.headers.get('content-type')
    if content_type and ';' in content_type:
        content_type = content_type.split(';')[0]
        logger.debug('Content type from response: %s', content_type)
    if operation.is_streaming():
        logger.debug(
            "Response Headers:\n%s",
            '\n'.join("%s: %s" % (k, v) for k, v in http_response.headers.items()))
        streaming_response = StreamingResponse(session, operation)
        streaming_response.parse(
            http_response.headers,
            StreamingBody(http_response.raw,
                          http_response.headers.get('content-length')))
        if http_response.ok:
            return (http_response, streaming_response.get_value())
        else:
            xml_response = XmlResponse(session, operation)
            body = streaming_response.get_value()['Body'].read()
            # For streaming response, response body might be binary data,
            # so we log response body only when error happens.
            logger.debug("Response Body:\n%s", body)
            if body:
                try:
                    xml_response.parse(body, encoding)
                except xml.etree.cElementTree.ParseError as err:
                    raise xml.etree.cElementTree.ParseError(
                        "Error parsing XML response: %s\nXML received:\n%s" % (err, body))
            return (http_response, xml_response.get_value())
    body = http_response.content
    if not http_response.request.method == 'HEAD':
        _validate_content_length(
            http_response.headers.get('content-length'), len(body))
    logger.debug(
        "Response Headers:\n%s",
        '\n'.join("%s: %s" % (k, v) for k, v in http_response.headers.items()))
    logger.debug("Response Body:\n%s", body)
    if operation.service.type in ('json', 'rest-json'):
        json_response = JSONResponse(session, operation)
        if body:
            json_response.parse(body, encoding)
        json_response.merge_header_values(http_response.headers)
        return (http_response, json_response.get_value())
    # We are defaulting to an XML response handler because many query
    # services send XML error responses but do not include a Content-Type
    # header.
    xml_response = XmlResponse(session, operation)
    if body:
        xml_response.parse(body, encoding)
    xml_response.merge_header_values(http_response.headers)
    return (http_response, xml_response.get_value())
        


src/b/o/botocore-HEAD/botocore/endpoint.py   botocore(Download)
            return (None, e)
        # This returns the http_response and the parsed_data.
        return (botocore.response.get_response(self.session, operation,
                                               http_response), None)
 

src/b/o/botocore-0.42.0/botocore/endpoint.py   botocore(Download)
            return (None, e)
        # This returns the http_response and the parsed_data.
        return (botocore.response.get_response(self.session, operation,
                                               http_response), None)
 

src/b/o/botocore-HEAD/tests/unit/response_parsing/test_response_parsing.py   botocore(Download)
 
import botocore.session
from botocore.response import XmlResponse, JSONResponse, get_response
from botocore.exceptions import IncompleteReadError
 
        put_object = self.s3.get_operation('PutObject')
        expected = {"ETag": '"b081e66e7e0c314285c655cafb4d1e71"'}
        response_data = get_response(self.session, put_object, http_response)[1]
        self.assertEqual(response_data, expected)
 
                        'mykey2': 'value2',
                    }}
        response_data = get_response(self.session, put_object,
                                     http_response)[1]
        self.assertEqual(response_data, expected)
                    }
        with self.assertRaises(IncompleteReadError):
            response_data = get_response(self.session, list_objects,
                                         http_response)[1]
 
                    "ServerSideEncryption": "AES256"
                    }
        response_data = get_response(self.session, put_object,
                                     http_response)[1]
        self.assertEqual(response_data, expected)

src/b/o/botocore-HEAD/tests/unit/test_response.py   botocore(Download)
        operation = s3.get_operation('GetObject')
 
        res = response.get_response(session, operation, http_response)
        self.assertTrue(isinstance(res[1]['Body'], response.StreamingBody))
        self.assertEqual(res[1]['ETag'],