Gathering detailed insights and metrics for front-on-finished
Gathering detailed insights and metrics for front-on-finished
Gathering detailed insights and metrics for front-on-finished
Gathering detailed insights and metrics for front-on-finished
npm install front-on-finished
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
394 Stars
288 Commits
42 Forks
18 Watching
2 Branches
29 Contributors
Updated on 16 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
96.7%
59
Compared to previous day
Last week
14.6%
196
Compared to previous week
Last month
53.8%
603
Compared to previous month
Last year
-52.2%
5,543
Compared to previous year
Execute a callback when a HTTP request closes, finishes, or errors.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
1$ npm install on-finished
1var onFinished = require('on-finished')
Attach a listener to listen for the response to finish. The listener will be invoked only once when the response finished. If the response finished to an error, the first argument will contain the error. If the response has already finished, the listener will be invoked.
Listening to the end of a response would be used to close things associated with the response, like open files.
Listener is invoked as listener(err, res)
.
1onFinished(res, function (err, res) {
2 // clean up open fds, etc.
3 // err contains the error if request error'd
4})
Attach a listener to listen for the request to finish. The listener will be invoked only once when the request finished. If the request finished to an error, the first argument will contain the error. If the request has already finished, the listener will be invoked.
Listening to the end of a request would be used to know when to continue after reading the data.
Listener is invoked as listener(err, req)
.
1var data = '' 2 3req.setEncoding('utf8') 4req.on('data', function (str) { 5 data += str 6}) 7 8onFinished(req, function (err, req) { 9 // data is read unless there is err 10})
Determine if res
is already finished. This would be useful to check and
not even start certain operations if the response has already finished.
Determine if req
is already finished. This would be useful to check and
not even start certain operations if the request has already finished.
The meaning of the CONNECT
method from RFC 7231, section 4.3.6:
The CONNECT method requests that the recipient establish a tunnel to the destination origin server identified by the request-target and, if successful, thereafter restrict its behavior to blind forwarding of packets, in both directions, until the tunnel is closed. Tunnels are commonly used to create an end-to-end virtual connection, through one or more proxies, which can then be secured using TLS (Transport Layer Security, [RFC5246]).
In Node.js, these request objects come from the 'connect'
event on
the HTTP server.
When this module is used on a HTTP CONNECT
request, the request is
considered "finished" immediately, due to limitations in the Node.js
interface. This means if the CONNECT
request contains a request entity,
the request will be considered "finished" even before it has been read.
There is no such thing as a response object to a CONNECT
request in
Node.js, so there is no support for one.
The meaning of the Upgrade
header from RFC 7230, section 6.1:
The "Upgrade" header field is intended to provide a simple mechanism for transitioning from HTTP/1.1 to some other protocol on the same connection.
In Node.js, these request objects come from the 'upgrade'
event on
the HTTP server.
When this module is used on a HTTP request with an Upgrade
header, the
request is considered "finished" immediately, due to limitations in the
Node.js interface. This means if the Upgrade
request contains a request
entity, the request will be considered "finished" even before it has been
read.
There is no such thing as a response object to a Upgrade
request in
Node.js, so there is no support for one.
The following code ensures that file descriptors are always closed once the response finishes.
1var destroy = require('destroy') 2var fs = require('fs') 3var http = require('http') 4var onFinished = require('on-finished') 5 6http.createServer(function onRequest (req, res) { 7 var stream = fs.createReadStream('package.json') 8 stream.pipe(res) 9 onFinished(res, function () { 10 destroy(stream) 11 }) 12})
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More