shazow/urllib3 — pull request #133 by bboe (2012-12-19 09:39:58+00:00)
Title: Close connection when no data is read.

As per the long discussion in PR #132 that originated with kennethreitz/requests#1041 the solution is to make sure to read the EOF marker in order for httplib to automatically shutdown the connection. This actually occurs already with httplib in all but one condition (how requests uses it).

While there is an [upstream fix](http://hg.python.org/cpython/rev/5d6c2c7bc5d4) not everyone will upgrade to the newest releases of python 2.7, 3.2, 3.3. This pull request fixes the behavior on urllib3 in a way that won't break if someone is running a version of python with the upstream fix (subsequent `close` calls have no effect).

I have verified that this fixes kennethreitz/requests#1041 when I applied this code to the version of urllib3 included with requests.