blob: 3a5de31cafbd49356da46a141374d25f011c5ac5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
common = require('../common');
assert = common.assert;
var net = require('net'),
util = require('util'),
http = require('http');
var errorCount = 0;
var eofCount = 0;
var server = net.createServer(function(socket) {
socket.end();
});
server.on('listening', function() {
var client = http.createClient(common.PORT);
client.addListener('error', function(err) {
console.log('ERROR! ' + (err.stack || err));
errorCount++;
});
client.addListener('end', function() {
console.log('EOF!');
eofCount++;
});
var request = client.request('GET', '/', {'host': 'localhost'});
request.end();
request.addListener('response', function(response) {
console.log('STATUS: ' + response.statusCode);
});
});
server.listen(common.PORT);
setTimeout(function() {
server.close();
}, 500);
process.addListener('exit', function() {
assert.equal(0, errorCount);
assert.equal(1, eofCount);
});
|