kennethreitz/requests — pull request #760 by slingamn (2012-08-06 04:03:46+00:00)
Title: address connection leak issue from #520

Piggybacking on the recent upgrade of urllib3 inside Requests, here's my much-delayed shot at a real fix for #520. From the commit message:

* prefetch now defaults to True, ensuring that by default, sockets
are returned to the urllib3 connection pool on request end
* sessions now have a close() method, notifying urllib3 to close pooled
connections
* the module-level API, e.g., `requests.get('http://www.google.com')`,
explicitly closes its session when finished

When prefetch is False, the open socket becomes part of the state of the
Response object, and it's the client's responsibility to read the whole
body, at which point the socket will be returned to the pool.