Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2019-07-17 01:30:14 +0300
committerisaacs <i@izs.me>2019-07-17 02:28:49 +0300
commit554b641d49d135ae8d137e83aa288897c32dacc6 (patch)
tree93eb750355e722ed98d585f5fd1626e68e32bfa0 /node_modules/agent-base
parente95da463cb7a325457ef411a569d7ef4bf76901d (diff)
dedupe: npm-registry-fetch@4.0.0
Diffstat (limited to 'node_modules/agent-base')
-rw-r--r--node_modules/agent-base/.travis.yml1
-rw-r--r--node_modules/agent-base/index.d.ts43
-rw-r--r--node_modules/agent-base/package.json31
-rw-r--r--node_modules/agent-base/patch-core.js46
-rw-r--r--node_modules/agent-base/test/test.js39
5 files changed, 124 insertions, 36 deletions
diff --git a/node_modules/agent-base/.travis.yml b/node_modules/agent-base/.travis.yml
index 6ce862c6f..76200951f 100644
--- a/node_modules/agent-base/.travis.yml
+++ b/node_modules/agent-base/.travis.yml
@@ -9,6 +9,7 @@ node_js:
- "7"
- "8"
- "9"
+ - "10"
install:
- PATH="`npm bin`:`npm bin -g`:$PATH"
diff --git a/node_modules/agent-base/index.d.ts b/node_modules/agent-base/index.d.ts
new file mode 100644
index 000000000..ff6788bdc
--- /dev/null
+++ b/node_modules/agent-base/index.d.ts
@@ -0,0 +1,43 @@
+// Type definitions for agent-base 4.2.1
+// Project: https://github.com/TooTallNate/node-agent-base
+// Definitions by: Christopher Quadflieg <https://github.com/Shinigami92>
+
+/// <reference types="node" />
+import { EventEmitter } from 'events';
+
+declare namespace Agent {
+ export type AgentCallback = (
+ req?: any,
+ opts?: {
+ secureEndpoint: boolean;
+ }
+ ) => void;
+
+ export interface AgentOptions {
+ timeout?: number;
+ host?: string;
+ port?: number;
+ [key: string]: any;
+ }
+
+ export interface Agent extends EventEmitter {
+ _promisifiedCallback: boolean;
+ timeout: number | null;
+ options?: AgentOptions;
+ callback: AgentCallback;
+ addRequest: (req?: any, opts?: any) => void;
+ freeSocket: (socket: any, opts: any) => void;
+ }
+}
+
+/**
+ * Base `http.Agent` implementation.
+ * No pooling/keep-alive is implemented by default.
+ */
+declare function Agent(opts?: Agent.AgentOptions): Agent.Agent;
+declare function Agent(
+ callback: Agent.AgentCallback,
+ opts?: Agent.AgentOptions
+): Agent.Agent;
+
+export = Agent;
diff --git a/node_modules/agent-base/package.json b/node_modules/agent-base/package.json
index 08c5330de..70da68723 100644
--- a/node_modules/agent-base/package.json
+++ b/node_modules/agent-base/package.json
@@ -1,31 +1,28 @@
{
- "_from": "agent-base@latest",
- "_id": "agent-base@4.2.1",
+ "_from": "agent-base@4",
+ "_id": "agent-base@4.3.0",
"_inBundle": false,
- "_integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==",
+ "_integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
"_location": "/agent-base",
"_phantomChildren": {},
"_requested": {
- "type": "tag",
+ "type": "range",
"registry": true,
- "raw": "agent-base@latest",
+ "raw": "agent-base@4",
"name": "agent-base",
"escapedName": "agent-base",
- "rawSpec": "latest",
+ "rawSpec": "4",
"saveSpec": null,
- "fetchSpec": "latest"
+ "fetchSpec": "4"
},
"_requiredBy": [
- "#USER",
- "/",
"/http-proxy-agent",
- "/https-proxy-agent",
- "/socks-proxy-agent"
+ "/https-proxy-agent"
],
- "_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz",
- "_shasum": "d89e5999f797875674c07d87f260fc41e83e8ca9",
- "_spec": "agent-base@latest",
- "_where": "/Users/zkat/Documents/code/work/npm",
+ "_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
+ "_shasum": "8165f01c436009bccad0b1d122f05ed770efc6ee",
+ "_spec": "agent-base@4",
+ "_where": "/Users/isaacs/dev/npm/cli/node_modules/http-proxy-agent",
"author": {
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net",
@@ -41,6 +38,8 @@
"deprecated": false,
"description": "Turn a function into an `http.Agent` instance",
"devDependencies": {
+ "@types/es6-promisify": "^5.0.0",
+ "@types/node": "^10.5.3",
"mocha": "^3.4.2",
"ws": "^3.0.0"
},
@@ -65,5 +64,5 @@
"scripts": {
"test": "mocha --reporter spec"
},
- "version": "4.2.1"
+ "version": "4.3.0"
}
diff --git a/node_modules/agent-base/patch-core.js b/node_modules/agent-base/patch-core.js
index 47d26a72b..21cbbb675 100644
--- a/node_modules/agent-base/patch-core.js
+++ b/node_modules/agent-base/patch-core.js
@@ -8,21 +8,25 @@ const https = require('https');
*
* 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);
- } else {
- options = Object.assign({}, _options);
- }
- if (null == options.port) {
- options.port = 443;
- }
- options.secureEndpoint = true;
- return request.call(https, options, cb);
- };
-})(https.request);
+const patchMarker = "__agent_base_https_request_patched__";
+if (!https.request[patchMarker]) {
+ https.request = (function(request) {
+ return function(_options, cb) {
+ let options;
+ if (typeof _options === 'string') {
+ options = url.parse(_options);
+ } else {
+ options = Object.assign({}, _options);
+ }
+ if (null == options.port) {
+ options.port = 443;
+ }
+ options.secureEndpoint = true;
+ return request.call(https, options, cb);
+ };
+ })(https.request);
+ https.request[patchMarker] = true;
+}
/**
* This is needed for Node.js >= 9.0.0 to make sure `https.get()` uses the
@@ -30,7 +34,17 @@ https.request = (function(request) {
*
* Ref: https://github.com/nodejs/node/commit/5118f31
*/
-https.get = function(options, cb) {
+https.get = function (_url, _options, cb) {
+ let options;
+ if (typeof _url === 'string' && _options && typeof _options !== 'function') {
+ options = Object.assign({}, url.parse(_url), _options);
+ } else if (!_options && !cb) {
+ options = _url;
+ } else if (!cb) {
+ options = _url;
+ cb = _options;
+ }
+
const req = https.request(options, cb);
req.end();
return req;
diff --git a/node_modules/agent-base/test/test.js b/node_modules/agent-base/test/test.js
index 6a8ca68e0..0f372c076 100644
--- a/node_modules/agent-base/test/test.js
+++ b/node_modules/agent-base/test/test.js
@@ -189,9 +189,10 @@ describe('Agent', function() {
})
};
var req = http.request(opts, function(res) {
- assert.equal('0.9', res.httpVersion);
- assert.equal(111, res.statusCode);
+ assert.equal('1.0', res.httpVersion);
+ assert.equal(200, res.statusCode);
assert.equal('bar', res.headers.foo);
+ assert.deepEqual(['1', '2'], res.headers['set-cookie']);
done();
});
@@ -199,8 +200,8 @@ describe('Agent', function() {
// doesn't *actually* attach the listeners to the "stream" until
// this happens
req.once('socket', function() {
- var buf = new Buffer(
- 'HTTP/0.9 111\r\n' +
+ var buf = Buffer.from(
+ 'HTTP/1.0 200\r\n' +
'Foo: bar\r\n' +
'Set-Cookie: 1\r\n' +
'Set-Cookie: 2\r\n\r\n'
@@ -541,6 +542,25 @@ describe('"https" module', function() {
});
});
+ it('should support the 3-argument `https.get()`', function(done) {
+ var agent = new Agent(function(req, opts, fn) {
+ assert.equal('google.com', opts.host);
+ assert.equal('/q', opts.pathname || opts.path);
+ assert.equal('881', opts.port);
+ assert.equal('bar', opts.foo);
+ done();
+ });
+
+ https.get(
+ 'https://google.com:881/q',
+ {
+ host: 'google.com',
+ foo: 'bar',
+ agent: agent
+ }
+ );
+ });
+
it('should default to port 443', function(done) {
var agent = new Agent(function(req, opts, fn) {
assert.equal(true, opts.secureEndpoint);
@@ -559,6 +579,17 @@ describe('"https" module', function() {
});
});
+ it('should not re-patch https.request', () => {
+ var patchModulePath = "../patch-core";
+ var patchedRequest = https.request;
+
+ delete require.cache[require.resolve(patchModulePath)];
+ require(patchModulePath);
+
+ assert.equal(patchedRequest, https.request);
+ assert.equal(true, https.request.__agent_base_https_request_patched__);
+ });
+
describe('PassthroughAgent', function() {
it('should pass through to `https.globalAgent`', function(done) {
// add HTTP server "request" listener