Sha256: 0cd74d1d50ae3f7c50451ca25ee0a6c5bec5dd0c38033e2747731c6d9f059b76

Contents?: true

Size: 987 Bytes

Versions: 5

Compression:

Stored size: 987 Bytes

Contents

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

var expected = 10000;
var responses = 0;
var requests = 0;
var connection;

var server = http.Server(function(req, res) {
  requests++;
  assert.equal(req.connection, connection);
  res.writeHead(200);
  res.end('hello world\n');
});

server.once('connection', function(c) {
  connection = c;
});

server.listen(common.PORT, function connect() {
  var request = http.get({
    port: common.PORT,
    path: '/',
    headers: {
      'Connection': 'Keep-alive'
    }
  }, function(res) {
    res.on('end', function() {
      if (++responses < expected) {
        connect();
      } else {
        server.close();
      }
    });
    res.resume();
  }).on('error', function(e) {
    console.log(e.message);
    process.exit(1);
  });
  request.agent.maxSockets = 1;
});

process.on('exit', function() {
  assert.equal(expected, responses);
  assert.equal(expected, requests);
});

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/pummel/test-http-many-keep-alive-connections.js
node-compiler-0.9.0 vendor/node-v7.2.1/test/pummel/test-http-many-keep-alive-connections.js
node-compiler-0.8.0 vendor/node-v7.2.0/test/pummel/test-http-many-keep-alive-connections.js
node-compiler-0.7.0 vendor/node-v6.9.1/test/pummel/test-http-many-keep-alive-connections.js
node-compiler-0.7.0 vendor/node-v7.1.0/test/pummel/test-http-many-keep-alive-connections.js