kennethreitz/requests — Issue #236: AttributeError while trying to read `content` attr
Author: unpluggd
Created: 2011-11-03 09:46:18+00:00
State: open

It seems that if there's a problem with obtaining the body of a request, `requests` throws an error while trying to read it.

Code:

```python
import requests

def main():
r = requests.get("some-flaky-url")
if not r.content:
raise Exception('content was flaky')
return r.content

main()
```

error:

```
Traceback (most recent call last):
File "test.py", line 5, in main:
if not r.content:
File "eggs/requests-0.7.4-py2.6.egg/requests/models.py", line 499, in content
self._content = self.raw.read()
AttributeError: 'NoneType' object has no attribute 'read'
```