diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js')
-rw-r--r-- | deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js index 7cdacafa3e..05cbaa1e70 100644 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js +++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/patch-core.js @@ -1,53 +1,25 @@ -var url = require('url'); -var http = require('http'); -var https = require('https'); -var semver = require('semver'); -var inherits = require('util').inherits; +'use strict'; +const url = require('url'); +const https = require('https'); -// we only need to patch the `http.request()` and -// `http.ClientRequest` on older versions of Node.js -if (semver.lt(process.version, '0.11.8')) { - // subclass the native ClientRequest to include the - // passed in `options` object. - http.ClientRequest = (function (_ClientRequest) { - function ClientRequest (options, cb) { - this._options = options; - _ClientRequest.call(this, options, cb); - } - inherits(ClientRequest, _ClientRequest); - - return ClientRequest; - })(http.ClientRequest); - - - // need to re-define the `request()` method, since on node v0.8/v0.10 - // the closure-local ClientRequest is used, rather than the monkey - // patched version we have created here. - http.request = (function (request) { - return function (options, cb) { - if (typeof options === 'string') { - options = url.parse(options); - } - if (options.protocol && options.protocol !== 'http:') { - throw new Error('Protocol:' + options.protocol + ' not supported.'); - } - return new http.ClientRequest(options, cb); - }; - })(http.request); -} - - -// this currently needs to be applied to all Node.js versions -// (v0.8.x, v0.10.x, v0.12.x), in order to determine if the `req` -// is an HTTP or HTTPS request. There is currently no PR attempting -// to move this property upstream. -https.request = (function (request) { - return function (options, cb) { +/** + * This currently needs to be applied to all Node.js versions + * in order to determine if the `req` is an HTTP or HTTPS request. + * + * There is currently no PR attempting to move this property upstream. + */ +https.request = (function(request) { + return function(_options, cb) { + let options if (typeof options === 'string') { - options = url.parse(options); + options = url.parse(_options); + } else { + options = Object.assign({}, _options); + } + if (null == options.port) { + options.port = 443; } - if (null == options.port) options.port = 443; options.secureEndpoint = true; return request.call(https, options, cb); }; |