httmock icon indicating copy to clipboard operation
httmock copied to clipboard

Add support for response.raw attribute.

Open seibert opened this issue 11 years ago • 3 comments

Response objects in requests are documented to contain a raw attribute that is a file-like object. When the request is made with stream=True, the raw attribute can be read to stream in the content. Otherwise, the raw attribute looks like a file-like object with no bytes left to read.

This PR adds support for the raw attribute and its behavior (at least how requests behaves currently).

seibert avatar Jun 27 '14 22:06 seibert

I feel this implementation is incorrect. It should use BytesIO and not StringIO, so that r.raw.read() returns bytes on Python 3.

I'm working on a patch for it.

garyvdm avatar Jul 04 '14 13:07 garyvdm

You are correct. I should have used BytesIO for Python 2 and 3 compatibility.

seibert avatar Jul 04 '14 19:07 seibert

Any news here? ;)

patrys avatar Aug 29 '14 13:08 patrys