2016-02-11 01:59:25 +01:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const agent = require('http').globalAgent;
|
|
|
|
|
|
|
|
// small stub just so we can call addRequest directly
|
|
|
|
const req = {
|
2017-03-24 17:46:44 +01:00
|
|
|
getHeader: common.noop
|
2016-02-11 01:59:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
agent.maxSockets = 0;
|
|
|
|
|
|
|
|
// localAddress is used when naming requests / sockets
|
|
|
|
// while using the Legacy API
|
|
|
|
agent.addRequest(req, 'localhost', common.PORT, '127.0.0.1');
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(Object.keys(agent.requests).length, 1);
|
|
|
|
assert.strictEqual(
|
2016-02-11 01:59:25 +01:00
|
|
|
Object.keys(agent.requests)[0],
|
|
|
|
'localhost:' + common.PORT + ':127.0.0.1');
|
|
|
|
|
|
|
|
// path is *not* used when naming requests / sockets
|
|
|
|
agent.addRequest(req, {
|
|
|
|
host: 'localhost',
|
|
|
|
port: common.PORT,
|
|
|
|
localAddress: '127.0.0.1',
|
|
|
|
path: '/foo'
|
|
|
|
});
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(Object.keys(agent.requests).length, 1);
|
|
|
|
assert.strictEqual(
|
2016-02-11 01:59:25 +01:00
|
|
|
Object.keys(agent.requests)[0],
|
|
|
|
'localhost:' + common.PORT + ':127.0.0.1');
|