diff options
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/agentkeepalive')
10 files changed, 0 insertions, 1118 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/History.md b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/History.md deleted file mode 100644 index 9db6e557..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/History.md +++ /dev/null @@ -1,248 +0,0 @@ - -4.2.1 / 2022-02-21 -================== - -**fixes** - * [[`8b13b5c`](http://github.com/node-modules/agentkeepalive/commit/8b13b5ca797f4779a0a8d393ad8ecb622cd27987)] - fix: explicitly set `| undefined` in type definitions (#99) (Benoit Lemoine <<lemoine.benoit@gmail.com>>) - -4.2.0 / 2021-12-31 -================== - -**fixes** - * [[`f418c67`](http://github.com/node-modules/agentkeepalive/commit/f418c67a63c061c7261592d4553bc455e0b0d306)] - fix: change `freeSocketTimeout` default value to 4000 (#102) (fengmk2 <<fengmk2@gmail.com>>) - -**others** - * [[`bc2a1ce`](http://github.com/node-modules/agentkeepalive/commit/bc2a1cea0884b4d18b0d244bf00006d9107963df)] - doc(readme): making `timeout`'s default clear (#100) (Aaron <<aaronarinder@gmail.com>>) - -4.1.4 / 2021-02-05 -================== - -**fixes** - * [[`4d04794`](http://github.com/node-modules/agentkeepalive/commit/4d047946b1547b4edff92ea40205aee4f0c8aa46)] - fix(types): correct `Https` constructor argument (#89) (Simen Bekkhus <<sbekkhus91@gmail.com>>) - -4.1.3 / 2020-06-15 -================== - -**fixes** - * [[`4ba9f9c`](http://github.com/node-modules/agentkeepalive/commit/4ba9f9c844f2a6b8037ce56599d25c69ef054d91)] - fix: compatible with node v12.16.3 (#91) (killa <<killa123@126.com>>) - -4.1.2 / 2020-04-25 -================== - -**fixes** - * [[`de66b02`](http://github.com/node-modules/agentkeepalive/commit/de66b0206d064a97129c2c31bcdabd4d64557b91)] - fix: detect http request timeout handler (#88) (fengmk2 <<fengmk2@gmail.com>>) - -4.1.1 / 2020-04-25 -================== - -**fixes** - * [[`bbd20c0`](http://github.com/node-modules/agentkeepalive/commit/bbd20c03b8cf7dfb00b3aad1ada26d4ab90d2d6e)] - fix: definition error (#87) (吖猩 <<whxaxes@qq.com>>) - -**others** - * [[`3b01699`](http://github.com/node-modules/agentkeepalive/commit/3b01699b8e90022d5f56898dd709e4fe7ee7cdaa)] - test: run test on node 12 (#84) (Igor Savin <<iselwin@gmail.com>>) - -4.1.0 / 2019-10-12 -================== - -**features** - * [[`fe33b80`](http://github.com/node-modules/agentkeepalive/commit/fe33b800acc09109388bfe65107550952b6fc7b0)] - feat: Add `reusedSocket` property on client request (#82) (Weijia Wang <<starkwang@126.com>>) - -**others** - * [[`77ba744`](http://github.com/node-modules/agentkeepalive/commit/77ba744667bb6b9e5986a53e5222f62094db12b9)] - docs: fix grammar in readme (#81) (Herrington Darkholme <<2883231+HerringtonDarkholme@users.noreply.github.com>>) - -4.0.2 / 2019-02-19 -================== - -**fixes** - * [[`56d4a9b`](http://github.com/node-modules/agentkeepalive/commit/56d4a9b2a4499ea28943ddb590358d7831a02cb1)] - fix: HttpAgent export = internal (#74) (Andrew Leedham <<AndrewLeedham@outlook.com>>) - -4.0.1 / 2019-02-19 -================== - -**fixes** - * [[`bad1ac0`](http://github.com/node-modules/agentkeepalive/commit/bad1ac0e710fbc486717e14e68c59266d35df6a8)] - fix: HttpsAgent Type Definition (#71) (#72) (Andrew Leedham <<AndrewLeedham@outlook.com>>) - * [[`f48a4a7`](http://github.com/node-modules/agentkeepalive/commit/f48a4a701ea6fbe43781c91e1c0aaad6e328ac7f)] - fix: export interface (#70) (Vinay <<vinaybedre@gmail.com>>) - -**others** - * [[`9124343`](http://github.com/node-modules/agentkeepalive/commit/91243437cfdd324cb97f39dee76746d5e5f4cd72)] - chore: add agent.options.keepAlive instead agent.keepAlive (fengmk2 <<fengmk2@gmail.com>>) - * [[`d177d40`](http://github.com/node-modules/agentkeepalive/commit/d177d40422fe7296990b4e270cf498e3f33c18fa)] - test: add request timeout bigger than agent timeout cases (fengmk2 <<fengmk2@gmail.com>>) - -4.0.0 / 2018-10-23 -================== - -**features** - * [[`5c9f3bb`](http://github.com/node-modules/agentkeepalive/commit/5c9f3bbd60555744edcf777105b148982a1a42b6)] - feat: impl the new Agent extend http.Agent (fengmk2 <<fengmk2@gmail.com>>) - -**others** - * [[`498c8f1`](http://github.com/node-modules/agentkeepalive/commit/498c8f13cf76600d3dd6e1c91cdf2d8292355dff)] - chore: move LICENSE from readme to file (fengmk2 <<fengmk2@gmail.com>>) - * [[`4f39894`](http://github.com/node-modules/agentkeepalive/commit/4f398942ba2f90cf4501239e56ac4e6344931a01)] - bugfix: support agent.options.timeout on https agent (fengmk2 <<fengmk2@gmail.com>>) - -3.5.2 / 2018-10-19 -================== - -**fixes** - * [[`5751fc1`](http://github.com/node-modules/agentkeepalive/commit/5751fc1180ed6544602c681ffbd08ca66a0cb12c)] - fix: sockLen being miscalculated when removing sockets (#60) (Ehden Sinai <<cixel@users.noreply.github.com>>) - -3.5.1 / 2018-07-31 -================== - -**fixes** - * [[`495f1ab`](http://github.com/node-modules/agentkeepalive/commit/495f1ab625d43945d72f68096b97db723d4f0657)] - fix: add the lost npm files (#66) (Henry Zhuang <<zhuanghengfei@gmail.com>>) - -3.5.0 / 2018-07-31 -================== - -**features** - * [[`16f5aea`](http://github.com/node-modules/agentkeepalive/commit/16f5aeadfda57f1c602652f1472a63cc83cd05bf)] - feat: add typing define. (#65) (Henry Zhuang <<zhuanghengfei@gmail.com>>) - -**others** - * [[`28fa062`](http://github.com/node-modules/agentkeepalive/commit/28fa06246fb5103f88ebeeb8563757a9078b8157)] - docs: add "per host" to description of maxFreeSockets (tony-gutierrez <<tony.gutierrez@bluefletch.com>>) - * [[`7df2577`](http://github.com/node-modules/agentkeepalive/commit/7df25774f00a1031ca4daad2878a17e0539072a2)] - test: run test on node 10 (#63) (fengmk2 <<fengmk2@gmail.com>>) - -3.4.1 / 2018-03-08 -================== - -**fixes** - * [[`4d3a3b1`](http://github.com/node-modules/agentkeepalive/commit/4d3a3b1f7b16595febbbd39eeed72b2663549014)] - fix: Handle ipv6 addresses in host-header correctly with TLS (#53) (Mattias Holmlund <<u376@m1.holmlund.se>>) - -**others** - * [[`55a7a5c`](http://github.com/node-modules/agentkeepalive/commit/55a7a5cd33e97f9a8370083dcb041c5552f10ac9)] - test: stop timer after test end (fengmk2 <<fengmk2@gmail.com>>) - -3.4.0 / 2018-02-27 -================== - -**features** - * [[`bc7cadb`](http://github.com/node-modules/agentkeepalive/commit/bc7cadb30ecd2071e2b341ac53ae1a2b8155c43d)] - feat: use socket custom freeSocketKeepAliveTimeout first (#59) (fengmk2 <<fengmk2@gmail.com>>) - -**others** - * [[`138eda8`](http://github.com/node-modules/agentkeepalive/commit/138eda81e10b632aaa87bea0cb66d8667124c4e8)] - doc: fix `keepAliveMsecs` params description (#55) (Hongcai Deng <<admin@dhchouse.com>>) - -3.3.0 / 2017-06-20 -================== - - * feat: add statusChanged getter (#51) - * chore: format License - -3.2.0 / 2017-06-10 -================== - - * feat: add expiring active sockets - * test: add node 8 (#49) - -3.1.0 / 2017-02-20 -================== - - * feat: timeout support humanize ms (#48) - -3.0.0 / 2016-12-20 -================== - - * fix: emit agent socket close event - * test: add remove excess calls to removeSocket - * test: use egg-ci - * test: refactor test with eslint rules - * feat: merge _http_agent.js from 7.2.1 - -2.2.0 / 2016-06-26 -================== - - * feat: Add browser shim (noop) for isomorphic use. (#39) - * chore: add security check badge - -2.1.1 / 2016-04-06 -================== - - * https: fix ssl socket leak when keepalive is used - * chore: remove circle ci image - -2.1.0 / 2016-04-02 -================== - - * fix: opened sockets number overflow maxSockets - -2.0.5 / 2016-03-16 -================== - - * fix: pick _evictSession to httpsAgent - -2.0.4 / 2016-03-13 -================== - - * test: add Circle ci - * test: add appveyor ci build - * refactor: make sure only one error listener - * chore: use codecov - * fix: handle idle socket error - * test: run on more node versions - -2.0.3 / 2015-08-03 -================== - - * fix: add default error handler to avoid Unhandled error event throw - -2.0.2 / 2015-04-25 -================== - - * fix: remove socket from freeSockets on 'timeout' (@pmalouin) - -2.0.1 / 2015-04-19 -================== - - * fix: add timeoutSocketCount to getCurrentStatus() - * feat(getCurrentStatus): add getCurrentStatus - -2.0.0 / 2015-04-01 -================== - - * fix: socket.destroyed always be undefined on 0.10.x - * Make it compatible with node v0.10.x (@lattmann) - -1.2.1 / 2015-03-23 -================== - - * patch from iojs: don't overwrite servername option - * patch commits from joyent/node - * add max sockets test case - * add nagle algorithm delayed link - -1.2.0 / 2014-09-02 -================== - - * allow set keepAliveTimeout = 0 - * support timeout on working socket. fixed #6 - -1.1.0 / 2014-08-28 -================== - - * add some socket counter for deep monitor - -1.0.0 / 2014-08-13 -================== - - * update _http_agent, only support 0.11+, only support node 0.11.0+ - -0.2.2 / 2013-11-19 -================== - - * support node 0.8 and node 0.10 - -0.2.1 / 2013-11-08 -================== - - * fix socket does not timeout bug, it will hang on life, must use 0.2.x on node 0.11 - -0.2.0 / 2013-11-06 -================== - - * use keepalive agent on node 0.11+ impl - -0.1.5 / 2013-06-24 -================== - - * support coveralls - * add node 0.10 test - * add 0.8.22 original https.js - * add original http.js module to diff - * update jscover - * mv pem to fixtures - * add https agent usage diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/LICENSE b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/LICENSE deleted file mode 100644 index 941258ca..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -The MIT License - -Copyright(c) node-modules and other contributors. -Copyright(c) 2012 - 2015 fengmk2 <fengmk2@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/README.md b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/README.md deleted file mode 100644 index 137935c1..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/README.md +++ /dev/null @@ -1,246 +0,0 @@ -# agentkeepalive - -[![NPM version][npm-image]][npm-url] -[![Known Vulnerabilities][snyk-image]][snyk-url] -[](https://github.com/node-modules/agentkeepalive/actions/workflows/nodejs.yml) -[![npm download][download-image]][download-url] - -[npm-image]: https://img.shields.io/npm/v/agentkeepalive.svg?style=flat -[npm-url]: https://npmjs.org/package/agentkeepalive -[snyk-image]: https://snyk.io/test/npm/agentkeepalive/badge.svg?style=flat-square -[snyk-url]: https://snyk.io/test/npm/agentkeepalive -[download-image]: https://img.shields.io/npm/dm/agentkeepalive.svg?style=flat-square -[download-url]: https://npmjs.org/package/agentkeepalive - -The enhancement features `keep alive` `http.Agent`. Support `http` and `https`. - -## What's different from original `http.Agent`? - -- `keepAlive=true` by default -- Disable Nagle's algorithm: `socket.setNoDelay(true)` -- Add free socket timeout: avoid long time inactivity socket leak in the free-sockets queue. -- Add active socket timeout: avoid long time inactivity socket leak in the active-sockets queue. -- TTL for active socket. - -## Node.js version required - -Support Node.js >= `8.0.0` - -## Install - -```bash -$ npm install agentkeepalive --save -``` - -## new Agent([options]) - -* `options` {Object} Set of configurable options to set on the agent. - Can have the following fields: - * `keepAlive` {Boolean} Keep sockets around in a pool to be used by - other requests in the future. Default = `true`. - * `keepAliveMsecs` {Number} When using the keepAlive option, specifies the initial delay - for TCP Keep-Alive packets. Ignored when the keepAlive option is false or undefined. Defaults to 1000. - Default = `1000`. Only relevant if `keepAlive` is set to `true`. - * `freeSocketTimeout`: {Number} Sets the free socket to timeout - after `freeSocketTimeout` milliseconds of inactivity on the free socket. - The default [server-side timeout](https://nodejs.org/api/http.html#serverkeepalivetimeout) is 5000 milliseconds, to [avoid ECONNRESET exceptions](https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83), we set the default value to `4000` milliseconds. - Only relevant if `keepAlive` is set to `true`. - * `timeout`: {Number} Sets the working socket to timeout - after `timeout` milliseconds of inactivity on the working socket. - Default is `freeSocketTimeout * 2` so long as that value is greater than or equal to 8 seconds, otherwise the default is 8 seconds. - * `maxSockets` {Number} Maximum number of sockets to allow per - host. Default = `Infinity`. - * `maxFreeSockets` {Number} Maximum number of sockets (per host) to leave open - in a free state. Only relevant if `keepAlive` is set to `true`. - Default = `256`. - * `socketActiveTTL` {Number} Sets the socket active time to live, even if it's in use. - If not set, the behaviour keeps the same (the socket will be released only when free) - Default = `null`. - -## Usage - -```js -const http = require('http'); -const Agent = require('agentkeepalive'); - -const keepaliveAgent = new Agent({ - maxSockets: 100, - maxFreeSockets: 10, - timeout: 60000, // active socket keepalive for 60 seconds - freeSocketTimeout: 30000, // free socket keepalive for 30 seconds -}); - -const options = { - host: 'cnodejs.org', - port: 80, - path: '/', - method: 'GET', - agent: keepaliveAgent, -}; - -const req = http.request(options, res => { - console.log('STATUS: ' + res.statusCode); - console.log('HEADERS: ' + JSON.stringify(res.headers)); - res.setEncoding('utf8'); - res.on('data', function (chunk) { - console.log('BODY: ' + chunk); - }); -}); -req.on('error', e => { - console.log('problem with request: ' + e.message); -}); -req.end(); - -setTimeout(() => { - if (keepaliveAgent.statusChanged) { - console.log('[%s] agent status changed: %j', Date(), keepaliveAgent.getCurrentStatus()); - } -}, 2000); - -``` - -### `getter agent.statusChanged` - -counters have change or not after last checkpoint. - -### `agent.getCurrentStatus()` - -`agent.getCurrentStatus()` will return a object to show the status of this agent: - -```js -{ - createSocketCount: 10, - closeSocketCount: 5, - timeoutSocketCount: 0, - requestCount: 5, - freeSockets: { 'localhost:57479:': 3 }, - sockets: { 'localhost:57479:': 5 }, - requests: {} -} -``` - -### Support `https` - -```js -const https = require('https'); -const HttpsAgent = require('agentkeepalive').HttpsAgent; - -const keepaliveAgent = new HttpsAgent(); -// https://www.google.com/search?q=nodejs&sugexp=chrome,mod=12&sourceid=chrome&ie=UTF-8 -const options = { - host: 'www.google.com', - port: 443, - path: '/search?q=nodejs&sugexp=chrome,mod=12&sourceid=chrome&ie=UTF-8', - method: 'GET', - agent: keepaliveAgent, -}; - -const req = https.request(options, res => { - console.log('STATUS: ' + res.statusCode); - console.log('HEADERS: ' + JSON.stringify(res.headers)); - res.setEncoding('utf8'); - res.on('data', chunk => { - console.log('BODY: ' + chunk); - }); -}); - -req.on('error', e => { - console.log('problem with request: ' + e.message); -}); -req.end(); - -setTimeout(() => { - console.log('agent status: %j', keepaliveAgent.getCurrentStatus()); -}, 2000); -``` - -### Support `req.reusedSocket` - -This agent implements the `req.reusedSocket` to determine whether a request is send through a reused socket. - -When server closes connection at unfortunate time ([keep-alive race](https://code-examples.net/en/q/28a8069)), the http client will throw a `ECONNRESET` error. Under this circumstance, `req.reusedSocket` is useful when we want to retry the request automatically. - -```js -const http = require('http'); -const Agent = require('agentkeepalive'); -const agent = new Agent(); - -const req = http - .get('http://localhost:3000', { agent }, (res) => { - // ... - }) - .on('error', (err) => { - if (req.reusedSocket && err.code === 'ECONNRESET') { - // retry the request or anything else... - } - }) -``` - -This behavior is consistent with Node.js core. But through `agentkeepalive`, you can use this feature in older Node.js version. - -## [Benchmark](https://github.com/node-modules/agentkeepalive/tree/master/benchmark) - -run the benchmark: - -```bash -cd benchmark -sh start.sh -``` - -Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz - -node@v0.8.9 - -50 maxSockets, 60 concurrent, 1000 requests per concurrent, 5ms delay - -Keep alive agent (30 seconds): - -```js -Transactions: 60000 hits -Availability: 100.00 % -Elapsed time: 29.70 secs -Data transferred: 14.88 MB -Response time: 0.03 secs -Transaction rate: 2020.20 trans/sec -Throughput: 0.50 MB/sec -Concurrency: 59.84 -Successful transactions: 60000 -Failed transactions: 0 -Longest transaction: 0.15 -Shortest transaction: 0.01 -``` - -Normal agent: - -```js -Transactions: 60000 hits -Availability: 100.00 % -Elapsed time: 46.53 secs -Data transferred: 14.88 MB -Response time: 0.05 secs -Transaction rate: 1289.49 trans/sec -Throughput: 0.32 MB/sec -Concurrency: 59.81 -Successful transactions: 60000 -Failed transactions: 0 -Longest transaction: 0.45 -Shortest transaction: 0.00 -``` - -Socket created: - -```bash -[proxy.js:120000] keepalive, 50 created, 60000 requestFinished, 1200 req/socket, 0 requests, 0 sockets, 0 unusedSockets, 50 timeout -{" <10ms":662," <15ms":17825," <20ms":20552," <30ms":17646," <40ms":2315," <50ms":567," <100ms":377," <150ms":56," <200ms":0," >=200ms+":0} ----------------------------------------------------------------- -[proxy.js:120000] normal , 53866 created, 84260 requestFinished, 1.56 req/socket, 0 requests, 0 sockets -{" <10ms":75," <15ms":1112," <20ms":10947," <30ms":32130," <40ms":8228," <50ms":3002," <100ms":4274," <150ms":181," <200ms":18," >=200ms+":33} -``` - -## License - -[MIT](LICENSE) - -## Contributors - -[](https://github.com/node-modules/agentkeepalive/graphs/contributors) diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/browser.js b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/browser.js deleted file mode 100644 index 29c9398a..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/browser.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = noop; -module.exports.HttpsAgent = noop; - -// Noop function for browser since native api's don't use agents. -function noop () {} diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.d.ts b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.d.ts deleted file mode 100644 index c2ce7d20..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as http from 'http'; -import * as https from 'https'; - -interface PlainObject { - [key: string]: any; -} - -declare class HttpAgent extends http.Agent { - constructor(opts?: AgentKeepAlive.HttpOptions); - readonly statusChanged: boolean; - createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void; - getCurrentStatus(): AgentKeepAlive.AgentStatus; -} - -interface Constants { - CURRENT_ID: Symbol; - CREATE_ID: Symbol; - INIT_SOCKET: Symbol; - CREATE_HTTPS_CONNECTION: Symbol; - SOCKET_CREATED_TIME: Symbol; - SOCKET_NAME: Symbol; - SOCKET_REQUEST_COUNT: Symbol; - SOCKET_REQUEST_FINISHED_COUNT: Symbol; -} - -declare class AgentKeepAlive extends HttpAgent {} - -declare namespace AgentKeepAlive { - export interface AgentStatus { - createSocketCount: number; - createSocketErrorCount: number; - closeSocketCount: number; - errorSocketCount: number; - timeoutSocketCount: number; - requestCount: number; - freeSockets: PlainObject; - sockets: PlainObject; - requests: PlainObject; - } - - interface CommonHttpOption { - keepAlive?: boolean | undefined; - freeSocketTimeout?: number | undefined; - freeSocketKeepAliveTimeout?: number | undefined; - timeout?: number | undefined; - socketActiveTTL?: number | undefined; - } - - export interface HttpOptions extends http.AgentOptions, CommonHttpOption { } - export interface HttpsOptions extends https.AgentOptions, CommonHttpOption { } - - export class HttpsAgent extends https.Agent { - constructor(opts?: HttpsOptions); - readonly statusChanged: boolean; - createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void; - getCurrentStatus(): AgentStatus; - } - - export const constants: Constants; -} - -export = AgentKeepAlive; diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.js b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.js deleted file mode 100644 index 6ca15134..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./lib/agent'); -module.exports.HttpsAgent = require('./lib/https_agent'); -module.exports.constants = require('./lib/constants'); diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/agent.js b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/agent.js deleted file mode 100644 index a7065b5e..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/agent.js +++ /dev/null @@ -1,398 +0,0 @@ -'use strict'; - -const OriginalAgent = require('http').Agent; -const ms = require('humanize-ms'); -const debug = require('debug')('agentkeepalive'); -const deprecate = require('depd')('agentkeepalive'); -const { - INIT_SOCKET, - CURRENT_ID, - CREATE_ID, - SOCKET_CREATED_TIME, - SOCKET_NAME, - SOCKET_REQUEST_COUNT, - SOCKET_REQUEST_FINISHED_COUNT, -} = require('./constants'); - -// OriginalAgent come from -// - https://github.com/nodejs/node/blob/v8.12.0/lib/_http_agent.js -// - https://github.com/nodejs/node/blob/v10.12.0/lib/_http_agent.js - -// node <= 10 -let defaultTimeoutListenerCount = 1; -const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1)); -if (majorVersion >= 11 && majorVersion <= 12) { - defaultTimeoutListenerCount = 2; -} else if (majorVersion >= 13) { - defaultTimeoutListenerCount = 3; -} - -class Agent extends OriginalAgent { - constructor(options) { - options = options || {}; - options.keepAlive = options.keepAlive !== false; - // default is keep-alive and 4s free socket timeout - // see https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83 - if (options.freeSocketTimeout === undefined) { - options.freeSocketTimeout = 4000; - } - // Legacy API: keepAliveTimeout should be rename to `freeSocketTimeout` - if (options.keepAliveTimeout) { - deprecate('options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); - options.freeSocketTimeout = options.keepAliveTimeout; - delete options.keepAliveTimeout; - } - // Legacy API: freeSocketKeepAliveTimeout should be rename to `freeSocketTimeout` - if (options.freeSocketKeepAliveTimeout) { - deprecate('options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); - options.freeSocketTimeout = options.freeSocketKeepAliveTimeout; - delete options.freeSocketKeepAliveTimeout; - } - - // Sets the socket to timeout after timeout milliseconds of inactivity on the socket. - // By default is double free socket timeout. - if (options.timeout === undefined) { - // make sure socket default inactivity timeout >= 8s - options.timeout = Math.max(options.freeSocketTimeout * 2, 8000); - } - - // support humanize format - options.timeout = ms(options.timeout); - options.freeSocketTimeout = ms(options.freeSocketTimeout); - options.socketActiveTTL = options.socketActiveTTL ? ms(options.socketActiveTTL) : 0; - - super(options); - - this[CURRENT_ID] = 0; - - // create socket success counter - this.createSocketCount = 0; - this.createSocketCountLastCheck = 0; - - this.createSocketErrorCount = 0; - this.createSocketErrorCountLastCheck = 0; - - this.closeSocketCount = 0; - this.closeSocketCountLastCheck = 0; - - // socket error event count - this.errorSocketCount = 0; - this.errorSocketCountLastCheck = 0; - - // request finished counter - this.requestCount = 0; - this.requestCountLastCheck = 0; - - // including free socket timeout counter - this.timeoutSocketCount = 0; - this.timeoutSocketCountLastCheck = 0; - - this.on('free', socket => { - // https://github.com/nodejs/node/pull/32000 - // Node.js native agent will check socket timeout eqs agent.options.timeout. - // Use the ttl or freeSocketTimeout to overwrite. - const timeout = this.calcSocketTimeout(socket); - if (timeout > 0 && socket.timeout !== timeout) { - socket.setTimeout(timeout); - } - }); - } - - get freeSocketKeepAliveTimeout() { - deprecate('agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead'); - return this.options.freeSocketTimeout; - } - - get timeout() { - deprecate('agent.timeout is deprecated, please use agent.options.timeout instead'); - return this.options.timeout; - } - - get socketActiveTTL() { - deprecate('agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead'); - return this.options.socketActiveTTL; - } - - calcSocketTimeout(socket) { - /** - * return <= 0: should free socket - * return > 0: should update socket timeout - * return undefined: not find custom timeout - */ - let freeSocketTimeout = this.options.freeSocketTimeout; - const socketActiveTTL = this.options.socketActiveTTL; - if (socketActiveTTL) { - // check socketActiveTTL - const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME]; - const diff = socketActiveTTL - aliveTime; - if (diff <= 0) { - return diff; - } - if (freeSocketTimeout && diff < freeSocketTimeout) { - freeSocketTimeout = diff; - } - } - // set freeSocketTimeout - if (freeSocketTimeout) { - // set free keepalive timer - // try to use socket custom freeSocketTimeout first, support headers['keep-alive'] - // https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498 - const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout; - return customFreeSocketTimeout || freeSocketTimeout; - } - } - - keepSocketAlive(socket) { - const result = super.keepSocketAlive(socket); - // should not keepAlive, do nothing - if (!result) return result; - - const customTimeout = this.calcSocketTimeout(socket); - if (typeof customTimeout === 'undefined') { - return true; - } - if (customTimeout <= 0) { - debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout); - return false; - } - if (socket.timeout !== customTimeout) { - socket.setTimeout(customTimeout); - } - return true; - } - - // only call on addRequest - reuseSocket(...args) { - // reuseSocket(socket, req) - super.reuseSocket(...args); - const socket = args[0]; - const req = args[1]; - req.reusedSocket = true; - const agentTimeout = this.options.timeout; - if (getSocketTimeout(socket) !== agentTimeout) { - // reset timeout before use - socket.setTimeout(agentTimeout); - debug('%s reset timeout to %sms', socket[SOCKET_NAME], agentTimeout); - } - socket[SOCKET_REQUEST_COUNT]++; - debug('%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - getSocketTimeout(socket)); - } - - [CREATE_ID]() { - const id = this[CURRENT_ID]++; - if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0; - return id; - } - - [INIT_SOCKET](socket, options) { - // bugfix here. - // https on node 8, 10 won't set agent.options.timeout by default - // TODO: need to fix on node itself - if (options.timeout) { - const timeout = getSocketTimeout(socket); - if (!timeout) { - socket.setTimeout(options.timeout); - } - } - - if (this.options.keepAlive) { - // Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/ - // https://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html - socket.setNoDelay(true); - } - this.createSocketCount++; - if (this.options.socketActiveTTL) { - socket[SOCKET_CREATED_TIME] = Date.now(); - } - // don't show the hole '-----BEGIN CERTIFICATE----' key string - socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split('-----BEGIN', 1)[0]; - socket[SOCKET_REQUEST_COUNT] = 1; - socket[SOCKET_REQUEST_FINISHED_COUNT] = 0; - installListeners(this, socket, options); - } - - createConnection(options, oncreate) { - let called = false; - const onNewCreate = (err, socket) => { - if (called) return; - called = true; - - if (err) { - this.createSocketErrorCount++; - return oncreate(err); - } - this[INIT_SOCKET](socket, options); - oncreate(err, socket); - }; - - const newSocket = super.createConnection(options, onNewCreate); - if (newSocket) onNewCreate(null, newSocket); - } - - get statusChanged() { - const changed = this.createSocketCount !== this.createSocketCountLastCheck || - this.createSocketErrorCount !== this.createSocketErrorCountLastCheck || - this.closeSocketCount !== this.closeSocketCountLastCheck || - this.errorSocketCount !== this.errorSocketCountLastCheck || - this.timeoutSocketCount !== this.timeoutSocketCountLastCheck || - this.requestCount !== this.requestCountLastCheck; - if (changed) { - this.createSocketCountLastCheck = this.createSocketCount; - this.createSocketErrorCountLastCheck = this.createSocketErrorCount; - this.closeSocketCountLastCheck = this.closeSocketCount; - this.errorSocketCountLastCheck = this.errorSocketCount; - this.timeoutSocketCountLastCheck = this.timeoutSocketCount; - this.requestCountLastCheck = this.requestCount; - } - return changed; - } - - getCurrentStatus() { - return { - createSocketCount: this.createSocketCount, - createSocketErrorCount: this.createSocketErrorCount, - closeSocketCount: this.closeSocketCount, - errorSocketCount: this.errorSocketCount, - timeoutSocketCount: this.timeoutSocketCount, - requestCount: this.requestCount, - freeSockets: inspect(this.freeSockets), - sockets: inspect(this.sockets), - requests: inspect(this.requests), - }; - } -} - -// node 8 don't has timeout attribute on socket -// https://github.com/nodejs/node/pull/21204/files#diff-e6ef024c3775d787c38487a6309e491dR408 -function getSocketTimeout(socket) { - return socket.timeout || socket._idleTimeout; -} - -function installListeners(agent, socket, options) { - debug('%s create, timeout %sms', socket[SOCKET_NAME], getSocketTimeout(socket)); - - // listener socket events: close, timeout, error, free - function onFree() { - // create and socket.emit('free') logic - // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L311 - // no req on the socket, it should be the new socket - if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return; - - socket[SOCKET_REQUEST_FINISHED_COUNT]++; - agent.requestCount++; - debug('%s(requests: %s, finished: %s) free', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - - // should reuse on pedding requests? - const name = agent.getName(options); - if (socket.writable && agent.requests[name] && agent.requests[name].length) { - // will be reuse on agent free listener - socket[SOCKET_REQUEST_COUNT]++; - debug('%s(requests: %s, finished: %s) will be reuse on agent free event', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - } - } - socket.on('free', onFree); - - function onClose(isError) { - debug('%s(requests: %s, finished: %s) close, isError: %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], isError); - agent.closeSocketCount++; - } - socket.on('close', onClose); - - // start socket timeout handler - function onTimeout() { - // onTimeout and emitRequestTimeout(_http_client.js) - // https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711 - const listenerCount = socket.listeners('timeout').length; - // node <= 10, default listenerCount is 1, onTimeout - // 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout - // node >= 13, default listenerCount is 3, onTimeout, - // onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333) - // and emitRequestTimeout - const timeout = getSocketTimeout(socket); - const req = socket._httpMessage; - const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0; - debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount); - if (debug.enabled) { - debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', ')); - } - agent.timeoutSocketCount++; - const name = agent.getName(options); - if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) { - // free socket timeout, destroy quietly - socket.destroy(); - // Remove it from freeSockets list immediately to prevent new requests - // from being sent through this socket. - agent.removeSocket(socket, options); - debug('%s is free, destroy quietly', socket[SOCKET_NAME]); - } else { - // if there is no any request socket timeout handler, - // agent need to handle socket timeout itself. - // - // custom request socket timeout handle logic must follow these rules: - // 1. Destroy socket first - // 2. Must emit socket 'agentRemove' event tell agent remove socket - // from freeSockets list immediately. - // Otherise you may be get 'socket hang up' error when reuse - // free socket and timeout happen in the same time. - if (reqTimeoutListenerCount === 0) { - const error = new Error('Socket timeout'); - error.code = 'ERR_SOCKET_TIMEOUT'; - error.timeout = timeout; - // must manually call socket.end() or socket.destroy() to end the connection. - // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback - socket.destroy(error); - agent.removeSocket(socket, options); - debug('%s destroy with timeout error', socket[SOCKET_NAME]); - } - } - } - socket.on('timeout', onTimeout); - - function onError(err) { - const listenerCount = socket.listeners('error').length; - debug('%s(requests: %s, finished: %s) error: %s, listenerCount: %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - err, listenerCount); - agent.errorSocketCount++; - if (listenerCount === 1) { - // if socket don't contain error event handler, don't catch it, emit it again - debug('%s emit uncaught error event', socket[SOCKET_NAME]); - socket.removeListener('error', onError); - socket.emit('error', err); - } - } - socket.on('error', onError); - - function onRemove() { - debug('%s(requests: %s, finished: %s) agentRemove', - socket[SOCKET_NAME], - socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - // We need this function for cases like HTTP 'upgrade' - // (defined by WebSockets) where we need to remove a socket from the - // pool because it'll be locked up indefinitely - socket.removeListener('close', onClose); - socket.removeListener('error', onError); - socket.removeListener('free', onFree); - socket.removeListener('timeout', onTimeout); - socket.removeListener('agentRemove', onRemove); - } - socket.on('agentRemove', onRemove); -} - -module.exports = Agent; - -function inspect(obj) { - const res = {}; - for (const key in obj) { - res[key] = obj[key].length; - } - return res; -} diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/constants.js b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/constants.js deleted file mode 100644 index ca7ab97e..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/constants.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - // agent - CURRENT_ID: Symbol('agentkeepalive#currentId'), - CREATE_ID: Symbol('agentkeepalive#createId'), - INIT_SOCKET: Symbol('agentkeepalive#initSocket'), - CREATE_HTTPS_CONNECTION: Symbol('agentkeepalive#createHttpsConnection'), - // socket - SOCKET_CREATED_TIME: Symbol('agentkeepalive#socketCreatedTime'), - SOCKET_NAME: Symbol('agentkeepalive#socketName'), - SOCKET_REQUEST_COUNT: Symbol('agentkeepalive#socketRequestCount'), - SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'), -}; diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/https_agent.js b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/https_agent.js deleted file mode 100644 index 73f529d6..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/lib/https_agent.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -const OriginalHttpsAgent = require('https').Agent; -const HttpAgent = require('./agent'); -const { - INIT_SOCKET, - CREATE_HTTPS_CONNECTION, -} = require('./constants'); - -class HttpsAgent extends HttpAgent { - constructor(options) { - super(options); - - this.defaultPort = 443; - this.protocol = 'https:'; - this.maxCachedSessions = this.options.maxCachedSessions; - /* istanbul ignore next */ - if (this.maxCachedSessions === undefined) { - this.maxCachedSessions = 100; - } - - this._sessionCache = { - map: {}, - list: [], - }; - } - - createConnection(options) { - const socket = this[CREATE_HTTPS_CONNECTION](options); - this[INIT_SOCKET](socket, options); - return socket; - } -} - -// https://github.com/nodejs/node/blob/master/lib/https.js#L89 -HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection; - -[ - 'getName', - '_getSession', - '_cacheSession', - // https://github.com/nodejs/node/pull/4982 - '_evictSession', -].forEach(function(method) { - /* istanbul ignore next */ - if (typeof OriginalHttpsAgent.prototype[method] === 'function') { - HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method]; - } -}); - -module.exports = HttpsAgent; diff --git a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/package.json b/sandbox/testAppNevena/Front/node_modules/agentkeepalive/package.json deleted file mode 100644 index efa561d2..00000000 --- a/sandbox/testAppNevena/Front/node_modules/agentkeepalive/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "agentkeepalive", - "version": "4.2.1", - "description": "Missing keepalive http.Agent", - "main": "index.js", - "browser": "browser.js", - "files": [ - "index.js", - "index.d.ts", - "browser.js", - "lib" - ], - "scripts": { - "test": "npm run lint && egg-bin test --full-trace", - "test-local": "egg-bin test --full-trace", - "cov": "cross-env DEBUG=agentkeepalive egg-bin cov --full-trace", - "ci": "npm run lint && npm run cov", - "lint": "eslint lib test index.js", - "autod": "autod" - }, - "repository": { - "type": "git", - "url": "git://github.com/node-modules/agentkeepalive.git" - }, - "bugs": { - "url": "https://github.com/node-modules/agentkeepalive/issues" - }, - "keywords": [ - "http", - "https", - "agent", - "keepalive", - "agentkeepalive", - "HttpAgent", - "HttpsAgent" - ], - "dependencies": { - "debug": "^4.1.0", - "depd": "^1.1.2", - "humanize-ms": "^1.2.1" - }, - "devDependencies": { - "autod": "^3.0.1", - "coffee": "^5.3.0", - "cross-env": "^6.0.3", - "egg-bin": "^4.9.0", - "egg-ci": "^1.10.0", - "eslint": "^5.7.0", - "eslint-config-egg": "^7.1.0", - "mm": "^2.4.1", - "pedding": "^1.1.0", - "typescript": "^3.8.3" - }, - "engines": { - "node": ">= 8.0.0" - }, - "ci": { - "type": "github", - "os": { - "github": "linux" - }, - "version": "8, 10, 12, 14, 16" - }, - "author": "fengmk2 <fengmk2@gmail.com> (https://fengmk2.com)", - "license": "MIT" -} |