Socket
Socket
Sign inDemoInstall

http-close

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http-close

gracefully close open sockets in a http server


Version published
Weekly downloads
12K
decreased by-3.87%
Maintainers
1
Install size
53.9 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 04 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc