Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

halt-on-dropped-connection.js 631 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. function isConnectionDropped (req, res) {
  2. // Have the flags been set for:
  3. // - a global request timeout (via the express-timeout-handler middleware)?
  4. // - an aborted request connection (via Node.js core's HTTP IncomingMessage)?
  5. return Boolean(res.globalTimeout || req.aborted)
  6. }
  7. function haltOnDroppedConnection (req, res, next) {
  8. // Only proceed if the flag has not been set for the express-timeout-handler middleware
  9. if (!isConnectionDropped(req, res)) {
  10. return next()
  11. }
  12. }
  13. // Export this logic, too
  14. haltOnDroppedConnection.isConnectionDropped = isConnectionDropped
  15. module.exports = haltOnDroppedConnection
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...