joyent/node — pull request #4912 by isaacs (2013-03-04 07:37:40+00:00)
Title: http: More useful setTimeout API on server

http: More useful setTimeout API on server

This adds the following to HTTP:

* server.setTimeout(msecs, callback)
Sets all new connections to time out after the specified time, at
which point it emits 'timeout' on the server, passing the socket as an
argument.
In this way, timeouts can be handled in one place consistently.
* req.setTimeout(), res.setTimeout()
Just aliases to req.socket.setTimeout() or res.socket.setTimeout(),
but without having to delve into a "buried" object.
* server.timeout
Number of milliseconds before incoming connections time out.
(Default=1000*60*2, as before.)

Furthermore, if the user sets up their own timeout listener on either
the server or the socket, then the default behavior (destroying the
socket) is suppressed.

Fix #3460