MCPcopy Create free account
hub / github.com/request/request / httpAgent

Function httpAgent

tests/test-agent.js:22–40  ·  view source on GitHub ↗
(t, options, req)

Source from the content-addressed store, hash-verified

20})
21
22function httpAgent (t, options, req) {
23 var r = (req || request)(options, function (_err, res, body) {
24 t.ok(r.agent instanceof http.Agent, 'is http.Agent')
25 t.equal(r.agent.options.keepAlive, true, 'is keepAlive')
26 t.equal(Object.keys(r.agent.sockets).length, 1, '1 socket name')
27
28 var name = (typeof r.agent.getName === 'function')
29 ? r.agent.getName({port: s.port})
30 : 'localhost:' + s.port // node 0.10-
31 t.equal(r.agent.sockets[name].length, 1, '1 open socket')
32
33 var socket = r.agent.sockets[name][0]
34 socket.on('close', function () {
35 t.equal(Object.keys(r.agent.sockets).length, 0, '0 open sockets')
36 t.end()
37 })
38 socket.end()
39 })
40}
41
42function foreverAgent (t, options, req) {
43 var r = (req || request)(options, function (_err, res, body) {

Callers 1

test-agent.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected