boto/boto — pull request #821 by jamesls (2012-06-15 01:42:00+00:00)
Title: Allow the HTTPResponse to be reread multiple times

There are potentially multiple things that would like
to process the returned HTTPResponse (error checking,
credential expiration, error class creation). However,
the first thing to call response.read() will see the response,
subsequent calls to response.read() will return, as expected,
an empty string.

This proposed fix is to cache the body of read() and return
the full body whenenever anyone calls read(). Admittedly, this
is not the most elegant way to do this, but the upside is that
this is a minimally invasive change.

This behavior is only enabled when there is no size passed to the
read() method. This ensures that any code streaming the response
in chunks remainins unaffected (from what I could tell, the keys
module in s3 is the only module doing this).

I've also added an integration test for this. This is the specific
error that was reported on the boto-dev mailing list, which was that
a 400 response from s3 did not have the S3ResponseError.error_code
populated. With these new changes, the test now passes.