Repository: psf/requests

Issue #2568: Keep-alive broken in 2.6.1 and 2.6.2 with chunked transfer-encoding
Created: 2015-04-24T12:41:40Z
Starting in 2.6.1 an exception is thrown if a connection with chunked transfer-encoding is reused. I suspect that the bug is in the bundled urllib3 which was upgraded from 1.10.2 to 1.10.3.
#!/usr/bin/env python
import requests
s = requests.Session()
r = s.get('http://httpbin.org/stream/1')
r.json()
r = s.get('http://httpbin.org/stream/1')
r.json()
$ ./test.py
Traceback (most recent call last):
  File "./test.py", line 10, in <module>
    r = s.get('http://httpbin.org/stream/1')
  File "[...]/requests/requests/sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "[...]/requests/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "[...]/requests/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "[...]/requests/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ResponseNotReady())

Duplicate issue #2579: ResponseNotReady when getting GitHub raw URL
Created: 2015-04-29T12:15:01Z
Trying to get https://github.com/kennethreitz/requests/blob/master/README.rst?raw=true fails. Getting https://github.com/kennethreitz/requests/raw/master/README.rst (which the former redirects to) succeeds, so I think this has something to do with the handling the redirect.
I'm not 100% sure this is an issue with requests (it's possible the server is misbehaving), but the same URL does work in the browser and in curl and wget.
$ python                                                                                                                                      bjwebb@winslow
Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__version__
'2.6.2'
>>> r = requests.get('https://github.com/kennethreitz/requests/blob/master/README.rst?raw=true')
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 372, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 374, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1162, in getresponse
    raise ResponseNotReady(self.__state)
http.client.ResponseNotReady: Request-sent

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 597, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 309, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 374, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1162, in getresponse
    raise ResponseNotReady(self.__state)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ResponseNotReady('Request-sent',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/site-packages/requests/api.py", line 68, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 594, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 594, in <listcomp>
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 196, in resolve_redirects
    **adapter_kwargs
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ResponseNotReady('Request-sent',))
>>>

Closing comment (2015-04-29T12:44:51Z): This is a duplicate of #2568.