diff --git a/index.js b/index.js index 21d1714..d60badb 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,6 @@ var util = require('util'); var zlib = require('zlib'); var querystring = require('querystring'); var objectAssign = require('object-assign'); -var infinityAgent = require('infinity-agent'); var duplexify = require('duplexify'); var isStream = require('is-stream'); var readAllStream = require('read-all-stream'); @@ -35,9 +34,7 @@ function got(url, opts, cb) { } opts = objectAssign( - { - protocol: 'http:' - }, + {protocol: 'http:'}, typeof url === 'string' ? urlLib.parse(prependHttp(url)) : url, opts ); @@ -110,29 +107,6 @@ function got(url, opts, cb) { var fn = opts.protocol === 'https:' ? https : http; var url = urlLib.format(opts); - if (opts.agent === undefined) { - opts.agent = infinityAgent[fn === https ? 'https' : 'http'].globalAgent; - - if (process.version.indexOf('v0.10') === 0 && fn === https && ( - typeof opts.ca !== 'undefined' || - typeof opts.cert !== 'undefined' || - typeof opts.ciphers !== 'undefined' || - typeof opts.key !== 'undefined' || - typeof opts.passphrase !== 'undefined' || - typeof opts.pfx !== 'undefined' || - typeof opts.rejectUnauthorized !== 'undefined')) { - opts.agent = new infinityAgent.https.Agent({ - ca: opts.ca, - cert: opts.cert, - ciphers: opts.ciphers, - key: opts.key, - passphrase: opts.passphrase, - pfx: opts.pfx, - rejectUnauthorized: opts.rejectUnauthorized - }); - } - } - var req = fn.request(opts, function (response) { var statusCode = response.statusCode; var res = response; diff --git a/readme.md b/readme.md index ca44f37..2c32cdd 100644 --- a/readme.md +++ b/readme.md @@ -102,14 +102,6 @@ Type: `number` Milliseconds after which the request will be aborted and an error event with `ETIMEDOUT` code will be emitted. -###### agent - -[http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) instance. - -If `undefined` - [`infinity-agent`](https://github.com/floatdrop/infinity-agent) will be used to backport Agent class from Node.js core. - -To use default [globalAgent](http://nodejs.org/api/http.html#http_http_globalagent) just pass `null`. - ##### callback(error, data, response) ###### error @@ -185,6 +177,18 @@ got('todomvc.com', { ``` +## Node 0.10 + +It is a known issue with Node [http.Agent](https://nodejs.org/docs/v0.10.39/api/http.html#http_class_http_agent) and `agent.maxSockets`, which is set to `5`. This can cause low performance of application and (in rare cases) deadlocks. To avoid this you can set it manually: + +```js +require('http').globalAgent.maxSockets = Infinity; +require('https').globalAgent.maxSockets = Infinity; +``` + +This should only ever be done at the top-level application layer. + + ## Related - [gh-got](https://github.com/sindresorhus/gh-got) - Convenience wrapper for interacting with the GitHub API