47fe3aaed602f4f31ca01843c64ada0feb842a98
[platform/upstream/nodejs.git] / deps / npm / node_modules / request / tests / test-agentOptions.js
1 var request = require('../index')
2   , http = require('http')
3   , server = require('./server')
4   , assert = require('assert')
5   ;
6
7 var s = http.createServer(function (req, resp) {
8   resp.statusCode = 200
9   resp.end('')
10 }).listen(6767, function () {
11   // requests without agentOptions should use global agent
12   var r = request('http://localhost:6767', function (e, resp, body) {
13     assert.deepEqual(r.agent, http.globalAgent);
14     assert.equal(Object.keys(r.pool).length, 0);
15
16     // requests with agentOptions should apply agentOptions to new agent in pool
17     var r2 = request('http://localhost:6767', { agentOptions: { foo: 'bar' } }, function (e, resp, body) {
18       assert.deepEqual(r2.agent.options, { foo: 'bar' });
19       assert.equal(Object.keys(r2.pool).length, 1);
20             s.close()
21          });
22   })
23 })