0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/pummel/test-http-client-reconnect-bug.js

46 lines
934 B
JavaScript
Raw Normal View History

2010-12-05 00:20:34 +01:00
var common = require('../common');
var assert = require('assert');
2010-12-03 02:03:18 +01:00
var net = require('net'),
util = require('util'),
http = require('http');
var errorCount = 0;
var eofCount = 0;
2010-08-11 02:37:30 +02:00
var server = net.createServer(function(socket) {
socket.end();
});
2010-12-03 02:03:18 +01:00
server.on('listening', function() {
2010-08-11 02:37:30 +02:00
var client = http.createClient(common.PORT);
2010-12-03 02:03:18 +01:00
client.addListener('error', function(err) {
console.log('ERROR! ' + err.message);
2010-08-11 02:37:30 +02:00
errorCount++;
});
2010-12-03 02:03:18 +01:00
client.addListener('end', function() {
console.log('EOF!');
2010-08-11 02:37:30 +02:00
eofCount++;
});
2010-12-03 02:03:18 +01:00
var request = client.request('GET', '/', {'host': 'localhost'});
2010-08-11 02:37:30 +02:00
request.end();
request.addListener('response', function(response) {
2010-12-03 02:03:18 +01:00
console.log('STATUS: ' + response.statusCode);
2010-08-11 02:37:30 +02:00
});
});
2010-08-11 02:37:30 +02:00
server.listen(common.PORT);
2010-12-03 02:03:18 +01:00
setTimeout(function() {
server.close();
}, 500);
2010-12-03 02:03:18 +01:00
process.addListener('exit', function() {
assert.equal(1, errorCount);
assert.equal(1, eofCount);
});