Sha256: c76c3776bd949cc3731bb73182daa1ddc01e726a9143fc76ba52b7507c72e12f

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

'use strict';
var common = require('../common');
var http = require('http');
var assert = require('assert');

var N = 20;
var responses = 0;
var maxQueued = 0;

var agent = http.globalAgent;
agent.maxSockets = 10;

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello World\n');
});

var addrString = agent.getName({ host: '127.0.0.1', port: common.PORT });

server.listen(common.PORT, '127.0.0.1', function() {
  for (var i = 0; i < N; i++) {
    var options = {
      host: '127.0.0.1',
      port: common.PORT
    };

    var req = http.get(options, function(res) {
      if (++responses === N) {
        server.close();
      }
      res.resume();
    });

    assert.equal(req.agent, agent);

    console.log('Socket: ' + agent.sockets[addrString].length + '/' +
                agent.maxSockets + ' queued: ' + (agent.requests[addrString] ?
                agent.requests[addrString].length : 0));

    var agentRequests = agent.requests[addrString] ?
        agent.requests[addrString].length : 0;

    if (maxQueued < agentRequests) {
      maxQueued = agentRequests;
    }
  }
});

process.on('exit', function() {
  assert.strictEqual(responses, N);
  assert.ok(maxQueued <= 10);
});

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/sequential/test-regress-GH-877.js
node-compiler-0.9.0 vendor/node-v7.2.1/test/sequential/test-regress-GH-877.js
node-compiler-0.8.0 vendor/node-v7.2.0/test/sequential/test-regress-GH-877.js
node-compiler-0.7.0 vendor/node-v6.9.1/test/sequential/test-regress-GH-877.js
node-compiler-0.7.0 vendor/node-v7.1.0/test/sequential/test-regress-GH-877.js