ProtocolError IncompleteRead using requests
<p>I got this wierd error when I tried to download some images using <code>requests</code> with quite a brief code as follows,</p>

<pre><code>import requests
import StringIO

r = requests.get(image_url, stream=True)
if r.status_code == 200:
    r.raw.decode_content = True
    data = StringIO.StringIO(r.raw.data)
    # other code to deal with data
</code></pre>

<p>then I get this error,</p>

<pre><code>ProtocolError: ('Connection broken: IncompleteRead(15060 bytes read, 55977 more expected)', IncompleteRead(15060 bytes read, 55977 more expected))
</code></pre>

<p>I googled similar problems, and try to force requests using HTTP/1.0 protocol like this,</p>

<pre><code>import httplib
httplib.HTTPConnection._http_vsn = 10
httplib.HTTPConnection._http_vsn_str = 'HTTP/1.0'
</code></pre>

<p>however, the server simply returns me an <code>403</code> status code.</p>

<p>By the way, what's more confusing is the <code>ProtocolError</code> does not happens every time but sometimes.</p>

<p>Any help would be very appreciated!</p>