title: Reusing TCP connection on Node.js HTTP Server
body: <p>I am using a <code>http.Server</code>object of the default <code>http</code> module (-> <a href="http://nodejs.org/api/http.html" rel="noreferrer">API</a>).</p>
  
  <p>If a client connects the <code>request</code> event is emmited by the server and a <code>http.ServerRequest</code>object is passed to the event handler. That request object emits the following three events:</p>
  
  <ul>
  <li>data (incoming data)</li>
  <li>end (request ended)</li>
  <li>close (connection closed)</li>
  </ul>
  
  <p>I want to keep the initial (TCP) connection of the client and reuse it for several requests. The client supports this behaviour as it sends the "Connection: keep-alive" header.</p>
  
  <p>But how do I realize this using node.js? My problem is that after the first request the <em>end</em> event is emitted, and just like the official API says about that event:</p>
  
  <blockquote>
    <p>Emitted exactly once for each request. After that, no more 'data'
    events will be emitted on the request.</p>
  </blockquote>
  
  <p>OK, I can't use that request. But is there any way to work on the same TCP connection and create a new request on it?</p>
  
  <p>Background: I am working on a proxy implementation. If the user accesses a website that uses <a href="http://www.innovation.ch/personal/ronald/ntlm.html" rel="noreferrer">NTLM </a> I have to stick to one connection for at least the three client requests that are required for that type of authentication to not run into <a href="http://www.benjaminathawes.com/blog/Lists/Posts/Post.aspx?ID=14" rel="noreferrer">this</a> problem.</p>
  
  <p>Do you have any idea what I might try?</p>
  
  <p>Thanks in advance!</p>