agentkeepalive
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -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; |
{ | ||
"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 () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65871
20
820
195
4
4
7