Did I find the right examples for you? yes no

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
Wrapper class for an http response body.

This provides a few additional conveniences that do not exist
in the urllib3 model:

    * Set the timeout on the socket (i.e read() timeouts)
    * Auto validation of content length, if the amount of bytes
      we read does not match the content length, an exception
      is raised.

src/b/o/botocore-HEAD/tests/unit/test_response.py   botocore(Download)
    def test_streaming_wrapper_validates_content_length(self):
        body = six.BytesIO(b'1234567890')
        stream = response.StreamingBody(body, content_length=10)
        self.assertEqual(stream.read(), b'1234567890')
 
    def test_streaming_body_with_invalid_length(self):
        body = six.BytesIO(b'123456789')
        stream = response.StreamingBody(body, content_length=10)
    def test_streaming_body_with_single_read(self):
        body = six.BytesIO(b'123456789')
        stream = response.StreamingBody(body, content_length=10)
        with self.assertRaises(IncompleteReadError):
            stream.read()