title: Using Python “requests” with existing socket connection
body: <p>The Python “requests” library is currently all the rage, because of the beautiful interface that it provides for making HTTP requests — but beneath it there seems to be many layers of indirection — sessions, HTTP adapters, and finally the mechanics of urllib3.</p>
  
  <p>Where in this stack of abstractions is the right place to intervene if I already hold an open socket, and want to use “requests” to send an HTTP response down that socket and receive a reply back?</p>
  
  <p>Without some kind of intervention (or customization?), the stack will try to create a new TCP/IP socket for me, but in my particular application my code is not called until a connection has already been established on my behalf, so I will need to convince Requests to talk on that existing socket if I want to be able to use Requests' features.</p>
  
  <p>The Requests library:</p>
  
  <p><a href="http://pypi.python.org/pypi/requests" rel="noreferrer">http://pypi.python.org/pypi/requests</a></p>
  
  <p><a href="https://github.com/kennethreitz/requests" rel="noreferrer">https://github.com/kennethreitz/requests</a></p>