diff options
author | FallenRiteMonk <fallenritemonk@gmail.com> | 2018-04-05 11:52:34 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-04-05 16:01:07 -0400 |
commit | 25a816dcda7b1db0929501acfe13f2fe5119759b (patch) | |
tree | d3df4377a11dfb643b5976d2048d9bb4ee527903 /deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js | |
parent | b29c36b80746733994257b7380245102bc3c4cd6 (diff) | |
download | android-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.tar.gz android-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.tar.bz2 android-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.zip |
deps: upgrade npm to 5.8.0
PR-URL: https://github.com/nodejs/node/pull/19560
Fixes: https://github.com/nodejs/node/issues/19271
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js')
-rw-r--r-- | deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js index 23814e2c32..da2e919835 100644 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js +++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js @@ -14,6 +14,10 @@ var events = require('events'); var inherits = require('util').inherits; var Agent = require('../'); +var PassthroughAgent = Agent(function(req, opts) { + return opts.secureEndpoint ? https.globalAgent : http.globalAgent; +}); + describe('Agent', function() { describe('subclass', function() { it('should be subclassable', function(done) { @@ -70,10 +74,10 @@ describe('Agent', function() { it('should be the Agent instance', function(done) { var called = false; var agent = new Agent(); - agent.callback = function () { + agent.callback = function() { called = true; assert.equal(this, agent); - } + }; var info = url.parse('http://127.0.0.1/foo'); info.agent = agent; var req = http.get(info); @@ -81,15 +85,15 @@ describe('Agent', function() { assert(/no Duplex stream was returned/.test(err.message)); done(); }); - }) + }); it('should be the Agent instance with callback signature', function(done) { var called = false; var agent = new Agent(); - agent.callback = function (req, opts, fn) { + agent.callback = function(req, opts, fn) { called = true; assert.equal(this, agent); fn(); - } + }; var info = url.parse('http://127.0.0.1/foo'); info.agent = agent; var req = http.get(info); @@ -97,8 +101,8 @@ describe('Agent', function() { assert(/no Duplex stream was returned/.test(err.message)); done(); }); - }) - }) + }); + }); describe('"error" event', function() { it('should be invoked on `http.ClientRequest` instance if `callback()` has not been defined', function( done @@ -201,13 +205,7 @@ describe('Agent', function() { 'Set-Cookie: 1\r\n' + 'Set-Cookie: 2\r\n\r\n' ); - if ('function' == typeof stream.ondata) { - // node <= v0.11.3 - stream.ondata(buf, 0, buf.length); - } else { - // node > v0.11.3 - stream.emit('data', buf); - } + stream.emit('data', buf); }); req.end(); @@ -399,6 +397,28 @@ describe('"http" module', function() { done(); }); }); + + describe('PassthroughAgent', function() { + it('should pass through to `http.globalAgent`', function(done) { + // add HTTP server "request" listener + var gotReq = false; + server.once('request', function(req, res) { + gotReq = true; + res.setHeader('X-Foo', 'bar'); + res.setHeader('X-Url', req.url); + res.end(); + }); + + var info = url.parse('http://127.0.0.1:' + port + '/foo'); + info.agent = PassthroughAgent; + http.get(info, function(res) { + assert.equal('bar', res.headers['x-foo']); + assert.equal('/foo', res.headers['x-url']); + assert(gotReq); + done(); + }); + }); + }); }); describe('"https" module', function() { @@ -426,7 +446,6 @@ describe('"https" module', function() { server.close(); }); - it('should not modify the passed in Options object', function(done) { var called = false; var agent = new Agent(function(req, opts, fn) { @@ -515,6 +534,29 @@ describe('"https" module', function() { rejectUnauthorized: false }); }); + + describe('PassthroughAgent', function() { + it('should pass through to `https.globalAgent`', function(done) { + // add HTTP server "request" listener + var gotReq = false; + server.once('request', function(req, res) { + gotReq = true; + res.setHeader('X-Foo', 'bar'); + res.setHeader('X-Url', req.url); + res.end(); + }); + + var info = url.parse('https://127.0.0.1:' + port + '/foo'); + info.agent = PassthroughAgent; + info.rejectUnauthorized = false; + https.get(info, function(res) { + assert.equal('bar', res.headers['x-foo']); + assert.equal('/foo', res.headers['x-url']); + assert(gotReq); + done(); + }); + }); + }); }); describe('"ws" server', function() { |