blob: cc3e41f3e92c778a0ad4219180110fe95d8fb68f (
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
|
var common = require('../common');
var assert = require('assert');
var http = require('http');
var server = http.Server(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
server.close();
});
var dataCount = 0, endCount = 0;
server.listen(common.PORT, function() {
var opts = {
port: common.PORT,
headers: { connection: 'close' }
};
http.get(opts, function(res) {
res.on('data', function(chunk) {
dataCount++;
res.pause();
setTimeout(function() {
res.resume();
});
});
res.on('end', function() {
endCount++;
});
});
});
process.on('exit', function() {
assert.equal(1, dataCount);
assert.equal(1, endCount);
});
|