I am using a http.Server
object of the default http
module (-> API).
If a client connects the request
event is emmited by the server and a http.ServerRequest
object is passed to the event handler. That request object emits the following three events:
- data (incoming data)
- end (request ended)
- close (connection closed)
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.
But how do I realize this using node.js? My problem is that after the first request the end event is emitted, and just like the official API says about that event:
Emitted exactly once for each request. After that, no more 'data' events will be emitted on the request.
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?
Background: I am working on a proxy implementation. If the user accesses a website that uses NTLM 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 this problem.
Do you have any idea what I might try?
Thanks in advance!