http-close
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

http-close

http-close keeps track on open sockets and closes them gracefully when the tcp server is closeing.

When you call server.close() this moudule will:

  • Destroy all sockets without a corresponding http response (keep-alive)
  • Send Connection: close to http requests where the headers is not sent
  • Set the socket timeout to the value you specify. Default 5 seconds.

When a socket timeouts after the server is closed, this module will respond with a 500 status code and end the connection where the headers is not sent. All other sockets will be destroyed.

Usage

var http = require('http')
  , httpClose = require('http-close')
 
var server = http.createServer()
 
// Add http-close hook
httpClose({ timeout: 2000 }, server)
 
// Just call server.close as usual when you want to stop the server
server.close()

Install

$ npm install http-close

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i http-close

Weekly Downloads

12,665

Version

1.0.0

License

MIT

Unpacked Size

6 kB

Total Files

8

Last publish

Collaborators

  • tellnes