Socket
Socket
Sign inDemoInstall

agentkeepalive

Package Overview
Dependencies
0
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.1.5

example/https_agent.js

12

lib/agent.js

@@ -19,2 +19,3 @@ /*!

var http = require('http');
var https = require('https');
var util = require('util');

@@ -141,2 +142,11 @@

return http.Agent.prototype.removeSocket.call(this, socket, name, host, port, localAddress);
};
};
function HttpsAgent(options) {
Agent.call(this, options);
this.createConnection = https.globalAgent.createConnection;
}
util.inherits(HttpsAgent, Agent);
HttpsAgent.prototype.defaultPort = 443;
Agent.HttpsAgent = HttpsAgent;

3

package.json
{
"name": "agentkeepalive",
"version": "0.1.4",
"version": "0.1.5",
"description": "Missing keepalive http.Agent",

@@ -27,2 +27,3 @@ "main": "index.js",

"mocha": "*",
"pedding": "*",
"visionmedia-jscoverage": "*"

@@ -29,0 +30,0 @@ },

@@ -6,3 +6,3 @@ agentkeepalive

The nodejs's missing `keep alive` `http.Agent`.
The nodejs's missing `keep alive` `http.Agent`. Support `http` and `https`.

@@ -58,2 +58,39 @@ jscoverage: [**93%**](http://fengmk2.github.com/coverage/agentkeepalive.html)

### Support `https`
```js
var https = require('https');
var HttpsAgent = require('agentkeepalive').HttpsAgent;
var keepaliveAgent = new HttpsAgent();
// https://www.google.com/search?q=nodejs&sugexp=chrome,mod=12&sourceid=chrome&ie=UTF-8
var options = {
host: 'www.google.com',
port: 443,
path: '/search?q=nodejs&sugexp=chrome,mod=12&sourceid=chrome&ie=UTF-8',
method: 'GET',
agent: keepaliveAgent
};
var req = https.request(options, function (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', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
setTimeout(function () {
console.log('keep alive sockets:');
console.log(keepaliveAgent.unusedSockets);
process.exit();
}, 2000);
```
## [Benchmark](https://github.com/TBEDP/agentkeepalive/tree/master/benchmark)

@@ -124,8 +161,8 @@

project: agentkeepalive
commits: 21
active : 9 days
files : 14
commits: 24
active : 10 days
files : 20
authors:
19 fengmk2 90.5%
2 Will White 9.5%
22 fengmk2 91.7%
2 Will White 8.3%
```

@@ -132,0 +169,0 @@

@@ -17,3 +17,3 @@ /*!

var should = require('should');
var pedding = require('./utils/pedding');
var pedding = require('pedding');

@@ -20,0 +20,0 @@ describe('agent.js', function () {

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