blob: bea0df38737a262e6bd6aa6f3be5bb6098fe5ccb (
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
|
var common = require('../common.js');
var assert = require('assert');
var http = require('http');
var msg = 'Hello';
var readable_event = false;
var end_event = false;
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(msg);
}).listen(common.PORT, function() {
http.get({port: common.PORT}, function(res) {
var data = '';
res.on('readable', function() {
console.log('readable event');
readable_event = true;
data += res.read();
});
res.on('end', function() {
console.log('end event');
end_event = true;
assert.strictEqual(msg, data);
server.close();
});
});
});
process.on('exit', function() {
assert(readable_event);
assert(end_event);
});
|