« Previous | Next » 

Revision d258fb02

IDd258fb0212530329b9941be18bc6e90d7afec5b5
Parent db5d58e8
Child 81c278d5

Added by isaacs over 11 years ago

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()
    Essentially an alias to req/res.socket.setTimeout(), but without
    having to delve into a "buried" object. Adds a listener on the
    req/res object, but not on the socket.
  • 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, the request, or the response, then the default behavior
(destroying the socket) is suppressed.

Fix #3460

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences